abci_query - Cosmos

Runs an ABCI query against the application at a given path, optionally at a historical height and with a Merkle proof. This is the low-level transport the Cosmos SDK gRPC/REST layer uses to read module state.

Method

abci_query

Parameters

ParameterTypeDescription
pathstringABCI query path, e.g. /cosmos.bank.v1beta1.Query/AllBalances
datastringHex-encoded request bytes
heightstringHeight to query (0 = latest)
provestringInclude a Merkle proof

Example

bashexport COSMOS_TM=https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/

# JSON-RPC over HTTP (POST)
curl -X POST "${COSMOS_TM}" -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": "getblock.io", "method": "abci_query", "params": {"path": "/cosmos.bank.v1beta1.Query/AllBalances", "data": "0x0a2b...", "height": "0", "prove": "false"}}'

# URI over HTTP (GET)
curl "${COSMOS_TM}abci_query?path=/cosmos.bank.v1beta1.Query/AllBalances&data=0x0a2b...&height=0&prove=false"

Response

json{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": {
    "response": {
      "code": 0,
      "value": "Cg0K...",
      "height": "31378844"
    }
  }
}

Response Fields

FieldTypeDescription
response.codenumberQuery result code (0 = success)
response.valuestringBase64-encoded response bytes (decode with the module's protobuf type)
response.heightstringHeight the query was run at

Use Cases

  • Raw state reads: Query any module's state by path

Error Handling

ErrorMessageDescription
-32600 / Invalid requestInvalid requestThe JSON-RPC envelope was malformed
-32602 / Invalid paramsInvalid paramsA parameter was missing or of the wrong type
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect