query call function - NEAR Protocol

Executes a read-only contract view method and returns its result, without creating a transaction. Uses method query with request_type call_function; args are base64-encoded JSON.

Method

query

Parameters

The params object carries:

ParameterExampleDescription
request_type"call_function"—
finality"final"—
account_id"example.near"—
method_name"ft_balance_of"—
args_base64"eyJhY2NvdW50X2lkIjoiZXhhbXBsZS5uZWFyIn0="—

Example

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

curl -X POST "${NEAR_RPC}" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": "getblock.io", "method": "query", "params": {"request_type": "call_function", "finality": "final", "account_id": "example.near", "method_name": "ft_balance_of", "args_base64": "eyJhY2NvdW50X2lkIjoiZXhhbXBsZS5uZWFyIn0="}}'

Response

json{
    "result": [
        49,
        50,
        53,
        48,
        48,
        48
    ],
    "logs": [],
    "block_height": 152000000,
    "block_hash": "9MzuZ..."
}

Response Fields

FieldTypeDescription
resultarrayThe method's return value as a byte array (decode to UTF-8/JSON)
logsarrayLogs emitted during the view call
block_heightnumberHeight the call was executed at

Use Cases

  • Contract reads: Call ft_balance_of, nft_tokens, or any view method
  • dApp UI: Populate views without submitting a transaction

Error Handling

ErrorMessageDescription
-32700 / Parse errorParse errorThe JSON request was malformed
-32601 / Method not foundMethod not foundThe method is unknown or disabled on this node version
HANDLER_ERRORRequested data not foundThe account, block, chunk, or transaction does not exist or is garbage-collected (use an archival node)
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect