POSTcall_function

NEAR Mainnethttps://near-mainnet.nodit.io/

Executes a contract's view method in read-only mode and returns its return value as a byte array and the logs emitted during execution as an array of strings. Because it does not change state, no transaction, signature, or gas fee is required.

Call the query method with request_type: "call_function". Pass the method arguments as a JSON string encoded in base64 in args_base64. For a method without arguments, pass e30=, which is {} encoded in base64. The returned result is an array of the bytes returned by the contract (usually UTF-8 JSON); convert the bytes to a UTF-8 string and parse it as JSON to get the original value. Decoding the result in the example yields {"spec":"ft-1.0.0","name":"Wrapped NEAR fungible token","symbol":"wNEAR","icon":null,"reference":null,"reference_hash":null,"decimals":24}.

Calling an account that does not exist returns the UNKNOWN_ACCOUNT error. If the method does not exist, no contract is deployed, or execution panics, the response carries the failure reason as a string in result.error instead of an RPC error (for example, wasm execution failed with error: MethodResolveError(MethodNotFound)).

Request Body
jsonrpcstringrequired
idstringrequired

Request ID. Any string; it is returned unchanged in the response.

methodstringrequired
request_typestring (enum)required

Query type. Fixed to call_function for calling a contract view method.

finalitystring (enum)

Specifies the block finality. Cannot be used together with block_id.

  • optimistic: the latest block the node has received (may be reorganized)
  • near-final: a Doomslug-final block (not reverted in most cases)
  • final: a fully finalized block
block_idinteger

Specifies the block to query by block height (integer) or block hash (base58 string). Cannot be used together with finality.

account_idstringrequired

NEAR account ID. A human-readable name (e.g. wrap.near) or a 64-character hex implicit account ID.

method_namestringrequired

Name of the contract method to call

args_base64stringrequired

Method arguments (a JSON string encoded in base64). If there are no arguments, pass e30=, which is {} encoded in base64.

Responses
jsonrpcstring

JSON-RPC version

idstring

Request ID

resultinteger[]

Byte array of the method's return value (each element is an integer from 0 to 255). Convert the bytes to a UTF-8 string, then parse it as JSON. Methods without a return value return an empty array.

logsstring[]

Logs emitted by the contract during execution. An empty array if there are no logs.

errorstring

Failure reason when contract execution fails (for example, method not found, no contract, or panic). Present only on failure, in which case the result field is absent.

block_heightinteger

Block height.

Example: 220785385

block_hashstring

Base58-encoded 32-byte hash (block hash, chunk hash, transaction hash, etc.).

Example: 8EjuQRnAJiWkRmqxfexQFJWXXonuSMbz5AZziJLCWnWS

namestring (enum)

Error class. REQUEST_VALIDATION_ERROR (invalid request), HANDLER_ERROR (processing error), INTERNAL_ERROR (node internal error)

causeobject

The specific cause of the error.

namestring

Name of the error cause (e.g. UNKNOWN_BLOCK, UNKNOWN_ACCOUNT, PARSE_ERROR)

infoobject

Additional information about the error (block hash, height, account ID, etc.)

codeinteger

Legacy JSON-RPC error code (e.g. -32000 server error, -32700 parse error, -32601 method not found)

messagestring

Legacy error message

datastring

Legacy error details

X-API-KEY
RequestCU60
cURL
curl -X POST "https://near-mainnet.nodit.io/" \
  -H "X-API-KEY: {YOUR_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": "dontcare",
    "method": "query",
    "params": {
      "request_type": "call_function",
      "finality": "final",
      "block_id": 220785385,
      "account_id": "wrap.near",
      "method_name": "ft_metadata",
      "args_base64": "e30="
    }
  }'
Response
Example · 200
{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "result": {
    "result": [
      123,
      34,
      115,
      112,
      101,
      99,
      34,
      58,
      34,
      102,
      116,
      45,
      49,
      46,
      48,
      46,
      48,
      34,
      44,
      34,
      110,
      97,
      109,
      101,
      34,
      58,
      34,
      87,
      114,
      97,
      112,
      112,
      101,
      100,
      32,
      78,
      69,
      65,
      82,
      32,
      102,
      117,
      110,
      103,
      105,
      98,
      108,
      101,
      32,
      116,
      111,
      107,
      101,
      110,
      34,
      44,
      34,
      115,
      121,
      109,
      98,
      111,
      108,
      34,
      58,
      34,
      119,
      78,
      69,
      65,
      82,
      34,
      44,
      34,
      105,
      99,
      111,
      110,
      34,
      58,
      110,
      117,
      108,
      108,
      44,
      34,
      114,
      101,
      102,
      101,
      114,
      101,
      110,
      99,
      101,
      34,
      58,
      110,
      117,
      108,
      108,
      44,
      34,
      114,
      101,
      102,
      101,
      114,
      101,
      110,
      99,
      101,
      95,
      104,
      97,
      115,
      104,
      34,
      58,
      110,
      117,
      108,
      108,
      44,
      34,
      100,
      101,
      99,
      105,
      109,
      97,
      108,
      115,
      34,
      58,
      50,
      52,
      125
    ],
    "logs": [],
    "block_height": 220785391,
    "block_hash": "FnRy8hpd2ESrs23uQ6vQrTQ8KRWrYsiq7Qv2UHDC8sRW"
  }
}