leo execute command executes Leo programs on the Aleo network, generating cryptographic proofs and optionally broadcasting transactions.
Syntax
Arguments
The function to execute. Can be:
- Function name only:
main - Qualified name:
hello_world.aleo/main
Program inputs in Aleo format:
- Literals:
1u32,true,5field - Records (plaintext):
{ owner: aleo1..., gates: 5u64 } - Records (ciphertext):
record1...(automatically decrypted)
Options
Network Options
Network type:
mainnet, testnet, or canary.Network endpoint URL. Examples:
- Mainnet:
https://api.explorer.provable.com/v1 - Testnet:
https://api.explorer.provable.com/v1 - Devnet:
http://localhost:3030
Private key to sign the transaction.
Whether the network is a devnet.
Custom consensus heights (comma-separated). For custom devnets only.
Fee Options
Priority fee in microcredits, delimited by
|. Use default for automatic calculation.Example: 1000|2000|defaultRecords to pay fees privately, delimited by
|. Use default for public fees.Example: record1abc...|defaultTransaction Actions
Broadcast the transaction to the network.
Print the transaction JSON to stdout.
Save the transaction to the specified directory.
Additional Options
Skip proof generation. Generates transaction without proof (for testing).
Skip confirmation prompts. Use with caution.
Consensus version to use (1-13). Auto-detected if not provided.
Seconds to wait for block confirmation.
Number of blocks to check for transaction confirmation.
Build Options
Don’t use the dependency cache.
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