Call read-only function

Calls a read-only public function on a given smart contract.

POST

/v2/contracts/call-read/{contract_address}/{contract_name}/{function_name}

Call a read-only public function on a given smart contract.

The smart contract and function are specified using the URL path. The arguments and the simulated tx-sender are supplied via the POST body in the following JSON format:

Request body

Map of arguments and the simulated tx-sender where sender is either a contract identifier or a normal Stacks address, and arguments is an array of hex serialized Clarity values.

sender
Required
string

The simulated tx-sender

arguments
Required
array of string

An array of hex serialized Clarity values

Path parameters

contract_address
Required
string

Stacks address

Example: "SP187Y7NRSG3T9Z9WTSWNEN3XRV1YSJWS81C7JKV7"

contract_name
Required
string

Contract name

Example: "imaginary-friends-zebras"

function_name
Required
string

Function name

Example: "get-token-uri"

Query parameters

tipstring

The Stacks chain tip to query from

Status codeDescription
200Success
Terminal
curl -X POST "https://api.mainnet.hiro.so/v2/contracts/call-read/SP187Y7NRSG3T9Z9WTSWNEN3XRV1YSJWS81C7JKV7/imaginary-friends-zebras/get-token-uri" \
  -d '{
  "sender": "string",
  "arguments": [
    "string"
  ]
}'

GET request to get contract source

Example response
{
  "okay": true,
  "result": "string",
  "cause": "string"
}