Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/provablehq/leo/llms.txt

Use this file to discover all available pages before exploring further.

The leo deploy command deploys Leo programs and their dependencies to the Aleo network, making them publicly available for execution.

Syntax

leo deploy [OPTIONS]

Options

Network Options

--network
string
required
Network type: mainnet, testnet, or canary.
--endpoint
string
required
Network endpoint URL:
  • Mainnet: https://api.explorer.provable.com/v1
  • Testnet: https://api.explorer.provable.com/v1
  • Devnet: http://localhost:3030
--private-key
string
required
Private key to sign deployment transactions.
Never deploy to mainnet with test private keys. Secure your private keys.
--devnet
boolean
default:false
Whether the network is a devnet.
--consensus-heights
string
Custom consensus heights (comma-separated) for custom devnets.

Fee Options

--priority-fees
string
Priority fees in microcredits for each deployment, delimited by |.Example: 1000|2000|default
--fee-records
string
Records to pay fees privately, delimited by |. Use default for public fees.

Transaction Actions

--broadcast
boolean
default:false
Broadcast deployment transactions to the network.
--print
boolean
default:false
Print deployment transactions as JSON to stdout.
--save
string
Save deployment transactions to the specified directory.

Deployment Options

--skip
string[]
Skip deployment of programs containing these substrings (comma-separated).Example: --skip test,old
--skip-deploy-certificate
boolean
default:false
Use placeholder certificate and verifying keys during deployment.
Only use for testing. Deployments with placeholder certificates are not secure.

Additional Options

-y, --yes
boolean
default:false
Skip confirmation prompts.
--consensus-version
number
Consensus version to use (1-13). Auto-detected if not provided.
--max-wait
number
default:8
Seconds to wait for block confirmation.
--blocks-to-check
number
default:12
Number of blocks to check for transaction confirmation.

Build Options

--no-cache
boolean
default:true
Don’t use the dependency cache. Always enabled for deploy.
--no-local
boolean
default:false
Use network versions of dependencies.

Examples

Deploy to Testnet

leo deploy \
  --broadcast \
  --private-key APrivateKey1zkp... \
  --network testnet \
  --endpoint https://api.explorer.provable.com/v1
Output:
🚀 Deployment Plan
──────────────────────────────────────────────
📦 Programs to Deploy (in order):
  1. my_lib.aleo
     • Status: Not on network
     • Size: 1.5 KB
     • Fee: ~5,234,567 μcredits

  2. hello_world.aleo
     • Status: Not on network  
     • Size: 2.3 KB
     • Fee: ~8,123,456 μcredits

💰 Total Estimated Cost: 13,358,023 μcredits (~0.013 credits)
──────────────────────────────────────────────

Do you want to proceed with deployment? [y/N]: y

📤 Deploying my_lib.aleo...
✅ Deployment confirmed!
   Transaction ID: at1abc...

📤 Deploying hello_world.aleo...
✅ Deployment confirmed!
   Transaction ID: at1def...

🎉 All programs deployed successfully!

Deploy with Priority Fee

leo deploy \
  --broadcast \
  --priority-fees 10000 \
  --private-key APrivateKey1zkp...
Priority fees help ensure faster deployment by incentivizing validators.

Deploy and Save Transactions

leo deploy \
  --save ./deployments \
  --private-key APrivateKey1zkp...
Saves deployment transactions to:
deployments/
├── my_lib.aleo.deployment.json
└── hello_world.aleo.deployment.json

Deploy and Print

leo deploy --print --private-key APrivateKey1zkp...
Prints deployment transactions as JSON without broadcasting.

Deploy Specific Program

leo deploy \
  --skip my_lib \
  --broadcast \
  --private-key APrivateKey1zkp...
Skips my_lib.aleo and deploys only hello_world.aleo.

Deploy to Devnet

leo deploy \
  --broadcast \
  --devnet \
  --network testnet \
  --endpoint http://localhost:3030 \
  --private-key APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH

Deploy Without Confirmation

leo deploy \
  --broadcast \
  --yes \
  --private-key APrivateKey1zkp...
Use --yes with caution. It skips all confirmation prompts including fee confirmations.

Deployment Flow

  1. Build Phase:
    • Compiles program and dependencies with --no-cache
    • Generates bytecode and certificates
  2. Plan Generation:
    • Determines deployment order (dependencies first)
    • Checks which programs already exist on network
    • Calculates deployment costs
  3. Cost Estimation:
    • Storage cost (proportional to program size)
    • Finalize cost (computational cost)
    • Priority fee (optional)
  4. User Confirmation:
    • Displays deployment plan
    • Shows total estimated cost
    • Prompts for confirmation (unless --yes)
  5. Deployment Execution:
    • For each program in order:
      • Generates deployment transaction
      • Authorizes fee (public or private)
      • Broadcasts transaction (if --broadcast)
      • Waits for confirmation
  6. Verification:
    • Confirms program exists on network
    • Verifies program matches local bytecode

Deployment Order

Programs are deployed in dependency order:
Dependencies → Dependents
Example:
my_lib.aleo     (no dependencies)

helper.aleo     (depends on my_lib)

app.aleo        (depends on helper)
Deployment order: my_libhelperapp

Cost Calculation

Deployment costs consist of:

Storage Cost

Based on program size:
Storage Cost = size_in_bytes * storage_rate

Finalize Cost

Based on deployment complexity:
Finalize Cost = base_cost + (num_imports * import_cost)

Priority Fee

Optional user-specified fee:
Priority Fee = user_specified_amount

Total Cost

Total = Storage Cost + Finalize Cost + Priority Fee
Costs are displayed in microcredits (μcredits). 1 credit = 1,000,000 microcredits.

Deployment Status

For each program, Leo checks network status:

Not on Network

• Status: Not on network
Program will be deployed.

Already Deployed (Matching)

• Status: On network (matches local)
Deployment skipped.

Already Deployed (Different)

⚠️ Status: On network (DOES NOT match local)
Deployment will fail. Update your program version or use a different name.

Transaction Format

Deployment transactions are saved as JSON:
{
  "type": "deploy",
  "id": "at1...",
  "owner": {
    "address": "aleo1...",
    "signature": "sign1..."
  },
  "deployment": {
    "edition": 0,
    "program": "program hello_world.aleo;\n...",
    "verifying_keys": [...],
    "certificate": "..."
  },
  "fee": {
    "transition": {...},
    "global_state_root": "sr1...",
    "proof": "..."
  }
}

Program Editions

Each deployment has an edition number:
  • Edition 0: Initial deployment
  • Edition 1+: Updates (if supported by network)
Most networks do not support program updates. Deploy with caution.

Verifying Keys and Certificates

Deployments include:

Verifying Keys

Cryptographic keys to verify program execution proofs.

Certificate

Proof that verifying keys were generated correctly.
Use --skip-deploy-certificate only for testing. Placeholder certificates are not secure.

Deployment Strategies

Development

# Deploy to local devnet
leo deploy \
  --broadcast \
  --devnet \
  --endpoint http://localhost:3030 \
  --private-key <TEST_KEY>

Staging

# Deploy to testnet
leo deploy \
  --broadcast \
  --network testnet \
  --endpoint https://api.explorer.provable.com/v1 \
  --private-key <TESTNET_KEY>

Production

# Deploy to mainnet
leo deploy \
  --broadcast \
  --network mainnet \
  --endpoint https://api.explorer.provable.com/v1 \
  --private-key <MAINNET_KEY> \
  --priority-fees 10000

Monitoring Deployments

Leo monitors deployment confirmation:
📤 Deploying hello_world.aleo...

Transaction ID: at1abc...
Fee ID: fi1def...

Waiting for confirmation...
 Deployment confirmed!
If deployment fails to confirm:
 Deployment not confirmed within 12 blocks.
    Transaction may still be pending.
    Check transaction ID: at1abc...

Troubleshooting

Program Already Exists

Program 'hello_world.aleo' already exists on the network.
Options:
  1. Use a different program name
  2. Deploy to a different network
  3. Wait for program update support (if applicable)

Insufficient Balance

Insufficient balance to pay deployment fee.
Ensure your account has enough credits:
leo query program credits.aleo/account/<your_address>/balance

Dependency Not Deployed

Dependency 'my_lib.aleo' is not deployed on the network.
Deploy dependencies first or include them in the deployment.

Network Unreachable

Failed to connect to network endpoint.
Check:
  1. Endpoint URL is correct
  2. Network is running
  3. Firewall allows connections

Best Practices

  1. Test Locally: Deploy to devnet before testnet/mainnet
  2. Verify Dependencies: Ensure all dependencies are deployed
  3. Review Costs: Check estimated costs before confirming
  4. Save Transactions: Use --save for record-keeping
  5. Monitor Confirmation: Wait for confirmation before assuming success
  6. Use Priority Fees: For time-sensitive deployments
  7. Backup Keys: Secure your private keys
  8. Version Control: Tag deployments in version control

Next Steps

Build docs developers (and LLMs) love