For the complete documentation index, see llms.txt. This page is also available as Markdown.

query call function - NEAR Protocol

Example code for the query call function JSON-RPC method. Complete guide on how to use query call function JSON-RPC in GetBlock Web3 documentation.

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:

Parameter
Example
Description

request_type

"call_function"

—

finality

"final"

—

account_id

"example.near"

—

method_name

"ft_balance_of"

—

args_base64

"eyJhY2NvdW50X2lkIjoiZXhhbXBsZS5uZWFyIn0="

—

Example

export 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

Response Fields

Field
Type
Description

result

array

The method's return value as a byte array (decode to UTF-8/JSON)

logs

array

Logs emitted during the view call

block_height

number

Height 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

Error
Message
Description

-32700 / Parse error

Parse error

The JSON request was malformed

-32601 / Method not found

Method not found

The method is unknown or disabled on this node version

HANDLER_ERROR

Requested data not found

The account, block, chunk, or transaction does not exist or is garbage-collected (use an archival node)

403 / RBAC: access denied

Access denied

The GetBlock access token is missing or incorrect

Was this helpful?