/wallet/triggerconstantcontract - Tron

This endpoint executes a read-only smart-contract call locally on the node, without creating a transaction. It is the primary method for reading contract state, such as a TRC-20 token balance, and returns the result in constant_result.

Parameters

ParameterTypeRequiredDescription
owner_addressstringYesCaller address
contract_addressstringYesThe contract address to call
function_selectorstringYesFunction signature, such as balanceOf(address)
parameterstringNoABI-encoded arguments, without the selector
visiblebooleanNoAccept and return addresses in base58 format

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/wallet/triggerconstantcontract' \
--header 'Content-Type: application/json' \
--data-raw '{
  "owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
  "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
  "function_selector": "balanceOf(address)",
  "parameter": "0000000000000000000000004142b5e01c8c59a25d78acdbec2bfc7e89e5e863",
  "visible": true
}'

example.js

javascriptconst response = await fetch(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/wallet/triggerconstantcontract',
    {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({"owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g", "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "function_selector": "balanceOf(address)", "parameter": "0000000000000000000000004142b5e01c8c59a25d78acdbec2bfc7e89e5e863", "visible": true})
    }
);
console.log(await response.json());

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/wallet/triggerconstantcontract',
    headers={'Content-Type': 'application/json'},
    json={"owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g", "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "function_selector": "balanceOf(address)", "parameter": "0000000000000000000000004142b5e01c8c59a25d78acdbec2bfc7e89e5e863", "visible": true}
)

print(response.json())

Response

json{
  "result": {
    "result": true
  },
  "constant_result": [
    "00000000000000000000000000000000000000000000000000000000000f4240"
  ],
  "energy_used": 1082
}

Response Parameters

FieldTypeDescription
result.resultbooleantrue when the call executed successfully
constant_resultarrayABI-encoded return data of the call, hex-encoded
energy_usedintegerEnergy the call would consume if run as a transaction

Use Cases

  • Token Balances: Read a TRC-20 balance with balanceOf
  • Contract State: Read view and pure functions without a transaction
  • Price Feeds: Query on-chain oracle values
  • Energy Estimation: Read energy_used to size a later transaction

Error Handling

HTTP StatusMessageDescription
200OKThe request succeeded; some TRON errors are returned in the 200 body as an Error field
400Bad requestThe request body is malformed or a required field is missing
500Internal errorThe node failed to process the request