call read - Stacks

Calls a read-only Clarity function and returns its result, without creating a transaction. Arguments are hex-encoded Clarity values; the result is a hex-encoded Clarity value.

Endpoint

httpPOST /v2/contracts/call-read/{deployer_address}/{contract_name}/{function_name}

Path Parameters

ParameterTypeDescription
deployer_addressstringThe contract deployer's standard address
contract_namestringThe contract name
function_namestringThe read-only function to call

Example

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

curl -X POST "${STACKS_RPC}v2/contracts/call-read/SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7/my-contract/get-balance" \
  -H "Content-Type: application/json" \
  -d '{"sender": "SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7", "arguments": ["0x0516a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3"]}'

Response

json{
  "okay": true,
  "result": "0x010000000000000000000000000000000a"
}

Response Fields

FieldTypeDescription
okaybooleanWhether the call succeeded
resultstringThe returned Clarity value, hex-encoded (present when okay is true)
causestringThe failure reason (present when okay is false)

Use Cases

  • Read state: Query balances, ownership, or any read-only getter
  • dApp UI: Populate views without submitting a transaction

Error Handling

ErrorMessageDescription
400 / Bad requestBad requestA path, query, or body parameter was invalid or the transaction was rejected
404 / Not foundNot foundThe account, contract, map entry, variable, or constant does not exist
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect