leo query command retrieves data from the Aleo network, including blocks, transactions, programs, and network state.
Syntax
Subcommands
block
Query block information.transaction
Query transaction information.program
Query program source code and mapping values.stateroot
Query the latest state root.committee
Query the current committee.mempool
Query transactions and transmissions from the memory pool.peers
Query peer information.Global Options
string
required
Network type:
mainnet, testnet, or canary.string
required
Network endpoint URL:
- Live networks:
https://api.explorer.provable.com/v1 - Custom node:
http://localhost:3030
Examples
Query Block
Latest Block
Block by Height
Block by Hash
Query Transaction
Query Program
Get Program Source
Get Program Mappings
Get Mapping Value
Query State Root
Query Committee
Query Mempool
Query Peers
Query URLs
The query command constructs URLs based on the subcommand:Block Queries
https://api.explorer.provable.com/v1/testnet/block/latesthttps://api.explorer.provable.com/v1/testnet/block/1000https://api.explorer.provable.com/v1/testnet/block/ab1...
Transaction Queries
https://api.explorer.provable.com/v1/testnet/transaction/at1...
Program Queries
https://api.explorer.provable.com/v1/testnet/program/hello_world.aleohttps://api.explorer.provable.com/v1/testnet/program/credits.aleo/mappingshttps://api.explorer.provable.com/v1/testnet/program/credits.aleo/mapping/account/aleo1.../balance
State Root Query
https://api.explorer.provable.com/v1/testnet/latest/stateRoot
Committee Query
https://api.explorer.provable.com/v1/testnet/committee/latest
Output Formats
Query results are output as:JSON
Structured data (blocks, transactions, committee)Plain Text
Simple values (state root, height, program source)Pretty Printed
Formatted for readability with success messagesCommon Use Cases
Check Account Balance
Verify Transaction Confirmed
Download Program Source
Monitor Latest Block
Check Network Height
Program Verification
When querying program source, Leo automatically verifies it’s valid:- Download the program source
- Parse it as Aleo bytecode
- Verify it’s valid
- Display the source
Using with Scripts
Bash Script
Python Script
Troubleshooting
Network Unreachable
- Endpoint URL is correct
- Network is running
- Internet connection active
- Firewall allows connections
Resource Not Found
- Verify the identifier is correct
- Check the program is deployed
- Ensure you’re querying the right network
Invalid Network
mainnettestnetcanary
Mempool/Peers Not Available
API Rate Limits
The public API may have rate limits:- Limit: ~100 requests per minute
- Throttling: Automatic backoff
- Alternatives: Run your own node