Skip to main content
The 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

Output:

Block by Height

Block by Hash

Query Transaction

Output:

Query Program

Get Program Source

Output:

Get Program Mappings

Get Mapping Value

Returns the balance for the specified account.

Query State Root

Output:

Query Committee

Output:

Query Mempool

The mempool endpoint is only available on custom nodes, not on the public API.
Output:

Query Peers

The peers endpoint is only available on custom nodes, not on the public API.
Output:

Query URLs

The query command constructs URLs based on the subcommand:

Block Queries

Examples:
  • https://api.explorer.provable.com/v1/testnet/block/latest
  • https://api.explorer.provable.com/v1/testnet/block/1000
  • https://api.explorer.provable.com/v1/testnet/block/ab1...

Transaction Queries

Example:
  • https://api.explorer.provable.com/v1/testnet/transaction/at1...

Program Queries

Examples:
  • https://api.explorer.provable.com/v1/testnet/program/hello_world.aleo
  • https://api.explorer.provable.com/v1/testnet/program/credits.aleo/mappings
  • https://api.explorer.provable.com/v1/testnet/program/credits.aleo/mapping/account/aleo1.../balance

State Root Query

Example:
  • https://api.explorer.provable.com/v1/testnet/latest/stateRoot

Committee Query

Example:
  • 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 messages

Common 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:
Leo will:
  1. Download the program source
  2. Parse it as Aleo bytecode
  3. Verify it’s valid
  4. Display the source
If invalid, an error is shown:

Using with Scripts

Bash Script

Python Script

Troubleshooting

Network Unreachable

Check:
  1. Endpoint URL is correct
  2. Network is running
  3. Internet connection active
  4. Firewall allows connections

Resource Not Found

The program/transaction/block doesn’t exist:
  1. Verify the identifier is correct
  2. Check the program is deployed
  3. Ensure you’re querying the right network

Invalid Network

Use valid network names:
  • mainnet
  • testnet
  • canary

Mempool/Peers Not Available

These endpoints require a direct node connection:

API Rate Limits

The public API may have rate limits:
  • Limit: ~100 requests per minute
  • Throttling: Automatic backoff
  • Alternatives: Run your own node

Next Steps