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 read-only function

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<string>

An array of hex serialized Clarity values

Path Parameters

contract_address
Required
string

Stacks address

Example: "SP3D6PV2ACBPEKYJTCMH7HEN02KP87QSP8KTEH335"

contract_name
Required
string

Contract name

Example: "mega"

function_name
Required
string

Function name

Example: "get-balance"

Query Parameters

tipstring

The Stacks chain tip to query from

Status codeDescription
200Success
/v2/contracts/call-read/{contract_address}/{contract_name}/{function_name}

curl -X POST "https://api.hiro.so/v2/contracts/call-read/SP3D6PV2ACBPEKYJTCMH7HEN02KP87QSP8KTEH335/mega/get-balance" \
  -H "Content-Type: application/json" \
  -d '{
    "sender": "SP187Y7NRSG3T9Z9WTSWNEN3XRV1YSJWS81C7JKV7",
    "arguments": [
      "0x0516da6b6c4a62ece9fa5a652278baa014ec83df3644"
    ]
  }'

GET request to get contract source

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