Skip to main content

leo query

The leo query command is used to get data from a network supporting the canonical snarkOS endpoints.

Subcommands

  • block - Query block information.
  • transaction - Query transaction information.
  • program - Query program source code and live mapping values.
  • stateroot - Query the latest stateroot.
  • committee - Query the current committee.
  • mempool - Query transactions and transmissions from the memory pool.
  • peers - Query peer information.

leo query block

To fetch blocks from a given network, run the following command

leo query <ID>

where <ID> is either a specific block height or block hash. The block will be returned in JSON format.

For example, you can fetch the Mainnet genesis block by running either of the following commands:

leo query block 0 --network mainnet --endpoint https://api.explorer.provable.com/v1
leo query block ab1sm6kyqle2ftg4z8gegafqrjy0jwjhzu6fmy73726dgszrtxhxvfqha0eee --network mainnet --endpoint https://api.explorer.provable.com/v1

Flags:

--network <NETWORK>

Specifies the network to deploy to. Overrides any NETWORK environment variable set manually or in a .env file. Valid network names are testnet, mainnet, and canary.

--endpoint <ENDPOINT>

The endpoint to deploy to. Overrides any ENDPOINT environment variable set manually or in a .env file.

--latest

-l

Queries the latest block.

Example:
leo query block --latest

--latest-hash

Queries the hash of the latest block.

Example:
leo query block --latest-hash

--latest-height

Queries the height of the latest block

Example:
leo query block --latest-height

--range <START_HEIGHT> <END_HEIGHT>

-r <START_HEIGHT> <END_HEIGHT>

Queries up to 50 consecutive blocks.

Example:
leo query block --range <START_HEIGHT> <END_HEIGHT>

--transactions

-t

Queries all transactions at the specified block height

Example:
leo query block <BLOCK_HEIGHT> --transactions

--to-height

Queries the block height corresponding to a hash value

Example:
leo query block <BLOCK_HASH> --to-height

leo query transaction

To fetch a specific transaction from a given network, run the following command:

leo query transaction <ID>

where <ID> is the ID of the transaction. The transaction will be returned in JSON format.

Flags:

--network <NETWORK>

Specifies the network to deploy to. Overrides any NETWORK environment variable set manually or in a .env file. Valid network names are testnet, mainnet, and canary.

--endpoint <ENDPOINT>

The endpoint to deploy to. Overrides any ENDPOINT environment variable set manually or in a .env file.

--confirmed

-c

Returns information (including details about onchain execution) about the queried transaction if it was confirmed.

--unconfirmed

-u

Queries the original (unconfirmed) transaction.

--from-io <INPUT_OR_OUTPUT_ID>

Get the ID of the transaction that an input or output ID occurred in.

Example:
leo query transaction --from-io <INPUT_OR_OUTPUT_ID>

--from-transition <TRANSITION_ID>

Get the ID of the transaction containing the specified transition.

Example:
leo query transaction --from-transition <TRANSITION_ID>

--from-program <PROGRAM_NAME>

Get the ID of the transaction that the specified program was deployed in.

Example:
leo query transaction --from-program <PROGRAM_NAME>

leo query program

To fetch a specific program from a given network, run the following command:

leo query program <PROGRAM_NAME>

You can also use this to query specific mappings and mapping values from a given program. For example, if you wanted to query your public balance of Aleo credits:

leo query program credits.aleo --mapping-value account <YOUR_ADDRESS>

Flags:

--network <NETWORK>

Specifies the network to deploy to. Overrides any NETWORK environment variable set manually or in a .env file. Valid network names are testnet, mainnet, and canary.

--endpoint <ENDPOINT>

The endpoint to deploy to. Overrides any ENDPOINT environment variable set manually or in a .env file.

--mappings

Lists all mappings defined in the latest deployed edition of the program.

--mapping-value <MAPPING> <KEY>

Get the value corresponding to the specified mapping and key. Will return null if key is not present in mapping.

--edition <EDITION>

An optional edition to query for when fetching the program source. If not specified, the latest edition will be used.

The edition of the program is set to 0 upon initial deployment and is incremented by 1 each time the program is upgraded. See the Upgrading Programs guide for more details.


leo query stateroot

This command queries the latest stateroot of a given network.

Flags:

--network <NETWORK>

Specifies the network to deploy to. Overrides any NETWORK environment variable set manually or in a .env file. Valid network names are testnet, mainnet, and canary.

--endpoint <ENDPOINT>

The endpoint to deploy to. Overrides any ENDPOINT environment variable set manually or in a .env file.


leo query committee

This command queries the current validator committee for a given network.

Flags:

--network <NETWORK>

Specifies the network to deploy to. Overrides any NETWORK environment variable set manually or in a .env file. Valid network names are testnet, mainnet, and canary.

--endpoint <ENDPOINT>

The endpoint to deploy to. Overrides any ENDPOINT environment variable set manually or in a .env file.


leo query mempool

This command queries transactions and transmissions from the memory pool for a node on a given network.

note

This command can only be run with a custom endpoint. Using the official Provable API endpoint will fail.

To query transactions:

leo query mempool --transactions

To query transmissions:

leo query mempool --transmissions

Flags:

--transactions

Queries the transactions in the memory pool.

--transmissions

Queries the transactions in the memory pool.

--network <NETWORK>

Specifies the network to deploy to. Overrides any NETWORK environment variable set manually or in a .env file. Valid network names are testnet, mainnet, and canary.

--endpoint <ENDPOINT>

The endpoint to deploy to. Overrides any ENDPOINT environment variable set manually or in a .env file.


leo query peers

This command queries peer information for a node on a given network.

note

This command can only be run with a custom endpoint. Using the official Provable API endpoint will fail.

Flags:

--metrics

-m

Queries all peer metrics

--count

-c

Queries the count of all participating peers

--network <NETWORK>

Specifies the network to deploy to. Overrides any NETWORK environment variable set manually or in a .env file. Valid network names are testnet, mainnet, and canary.

--endpoint <ENDPOINT>

The endpoint to deploy to. Overrides any ENDPOINT environment variable set manually or in a .env file.