Query Balances
This guide will cover the following query methods:
mnovad& Tendermint RPCJSON-RPC
gRPC
mnovad & Tendermint RPC
mnovad & Tendermint RPCUpon installation and configuration of the Metanovaverse Daemon, developers can query account balances using mnovad with the following CLI command:
$ mnovad query bank balances $MNOVAADDRESS --count-total=$COUNTTOTAL --height=$HEIGHT --output=$OUTPUT --node=$NODE
balances:
- amount: "1000000000000000000"
denom: amnv
- amount: "100000"
denom: ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518
pagination:
next_key: null
total: "0"where:
$MNOVAADDRESSis the Metanovaverse address with balances of interest (eg. mnova...).(optional)
$COUNTTOTALcounts the total number of records in all balances to query for.(optional)
$HEIGHTis the specific height to query state at (can error if node is pruning state).(optional)
$OUTPUTis the output format (eg.text).(optional if running local node)
$NODEis the Tendermint RPC node information is requested from
Details of non-native currencies can be queried with the following CLI command:
where $DENOM is the denomination of the coin (eg. ibc/ED07A3391A1...).
JSON-RPC
Developers can query account balances of amnv using the eth_getBalance JSON-RPC method in conjunction with curl:
where:
$ETHADDRESSis the Etherum hex-address the balance is to be queried from. Note that MNOVA addresses$BLOCKis the block number or block hash (eg."0x0"). The reasoning for this parameter is due to EIP-1898.(optional if running local node)
$NODEis the JSON-RPC node information is requested from
Developers can also query account balances of x/erc20-module registered coins using the eth_call JSON-RPC method in conjunction with curl:
where:
$SENDERCONTRACTADDRESSis the Ethereum hex-address this smart contract call is sent from.$ERCCONTRACTADDRESSis the Ethereum hex-address of the ERC-20 contract corresponding to the coin denomination being queried.$DATAis the hash of thebalanceofmethod signature and encoded parameters.balanceOfis a required method in every ERC-20 contract, and the encoded parameter is the address which is having its balance queried. For additional information, see the Ethereum Contract ABI.$BLOCKis the block number or block hash (eg."0x0"). The reasoning for this parameter is due to EIP-1898.(optional if running local node)
$NODEis the JSON-RPC node information is requested from
gRPC
Developers can use grpcurl with the AllBalances endpoint to query account balance by address for all denominations:
where:
$MNVADDRESSis the Metanovaverse address with balances of interest (eg."mnova...").$NODEis the Cosmos gRPC node information is requested(optional)
$OUTPUTis the output format (eg.plaintext).
State can also be queried using gRPC within a Go program. The idea is to create a gRPC connection, then use the Protobuf-generated client code to query the gRPC server.
Last updated