leo execute command executes Leo programs on the Aleo network, generating cryptographic proofs and optionally broadcasting transactions.
Syntax
Arguments
string
default:"main"
The function to execute. Can be:
- Function name only:
main - Qualified name:
hello_world.aleo/main
string[]
Program inputs in Aleo format:
- Literals:
1u32,true,5field - Records (plaintext):
{ owner: aleo1..., gates: 5u64 } - Records (ciphertext):
record1...(automatically decrypted)
Options
Network Options
string
required
Network type:
mainnet, testnet, or canary.string
required
Network endpoint URL. Examples:
- Mainnet:
https://api.explorer.provable.com/v1 - Testnet:
https://api.explorer.provable.com/v1 - Devnet:
http://localhost:3030
string
required
Private key to sign the transaction.
boolean
default:false
Whether the network is a devnet.
string
Custom consensus heights (comma-separated). For custom devnets only.
Fee Options
string
Priority fee in microcredits, delimited by
|. Use default for automatic calculation.Example: 1000|2000|defaultstring
Records to pay fees privately, delimited by
|. Use default for public fees.Example: record1abc...|defaultTransaction Actions
boolean
default:false
Broadcast the transaction to the network.
boolean
default:false
Print the transaction JSON to stdout.
string
Save the transaction to the specified directory.
Additional Options
boolean
default:false
Skip proof generation. Generates transaction without proof (for testing).
boolean
default:false
Skip confirmation prompts. Use with caution.
number
Consensus version to use (1-13). Auto-detected if not provided.
number
default:8
Seconds to wait for block confirmation.
number
default:12
Number of blocks to check for transaction confirmation.
Build Options
boolean
default:false
Don’t use the dependency cache.
boolean
default:false
Use network versions of dependencies.
Examples
Execute and Print
Execute and Broadcast
Execute with Priority Fee
Priority fees increase the likelihood of faster transaction inclusion by validators.
Execute with Private Fee
Execute and Save
./transactions/transaction.execution.json.
Execute Remote Program
Skip Proof Generation (Testing)
Execute with Custom Consensus Version
Execute Without Confirmation
Execution Flow
-
Build Phase:
- Compiles the program if in a Leo project
- Resolves and downloads dependencies
-
VM Initialization:
- Creates VM with consensus store
- Initializes query interface for network state
-
Program Loading:
- Loads local or remote programs
- Adds programs to VM in dependency order
-
Authorization:
- Generates authorization for function execution
- Creates proof (unless
--skip-execute-proof)
-
Cost Estimation:
- Calculates storage and execution costs
- Displays cost summary
-
Fee Authorization:
- Generates fee authorization (public or private)
- Uses provided priority fee if specified
-
Transaction Creation:
- Combines execution and fee
- Produces final transaction
-
Broadcasting (if
--broadcast):- Confirms fee with user
- Broadcasts to network
- Monitors for confirmation
Cost Breakdown
Execution costs consist of:Storage Cost
Cost to store transaction data on-chain:- Proportional to transaction size
- Measured in microcredits
Execution Cost
Cost to execute the program:- Based on computational complexity
- Number of constraints in the circuit
Priority Fee
Optional fee to prioritize transaction:- Higher fees increase inclusion likelihood
- Goes to block validators
Total Cost
Transaction Confirmation
After broadcasting, Leo monitors the transaction:- Broadcasts transaction to mempool
- Waits for inclusion in a block (up to
--max-waitseconds per block) - Checks recent blocks (up to
--blocks-to-checkblocks) - Reports success or timeout
JSON Output Format
With--print or --save, transactions are in JSON format:
Warnings
Leo displays warnings for:Program Mismatch
- Deploy your local version, or
- Use
--no-localto use the network version
Program Not on Network
- Deploy the program first with
leo deploy
Consensus Version Mismatch
- Verify your endpoint is correct
- Use
--consensus-versionto override
Troubleshooting
Insufficient Balance
Transaction Rejected
- Invalid inputs
- Program not deployed
- Insufficient fee
- Consensus version mismatch
Confirmation Timeout
Best Practices
- Test First: Use
leo runfor rapid testing before executing on-chain - Verify Costs: Review cost summaries before confirming
- Use Priority Fees: For time-sensitive transactions
- Save Transactions: Use
--savefor record-keeping - Monitor Confirmation: Wait for confirmation before assuming success