For the complete documentation index, see llms.txt. This page is also available as Markdown.

/walletsolidity/triggerconstantcontract - Tron

Example code for the triggerconstantcontract Solidity API method. Complete guide on how to use triggerconstantcontract Solidity API method in GetBlock Web3 documentation.

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.

This is a Solidity-node endpoint. It returns only confirmed, irreversible data, so it is the correct interface for balance and payment verification. The Fullnode serves the same operation at https://go.getblock.io/<ACCESS-TOKEN>/wallet/triggerconstantcontract over the latest, possibly unconfirmed state.

Parameters

Parameter
Type
Required
Description

owner_address

string

Yes

Caller address

contract_address

string

Yes

The contract address to call

function_selector

string

Yes

Function signature, such as balanceOf(address)

parameter

string

No

ABI-encoded arguments, without the selector

visible

boolean

No

Accept and return addresses in base58 format

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/walletsolidity/triggerconstantcontract' \
--header 'Content-Type: application/json' \
--data-raw '{
  "owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
  "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
  "function_selector": "balanceOf(address)",
  "parameter": "0000000000000000000000004142b5e01c8c59a25d78acdbec2bfc7e89e5e863",
  "visible": true
}'
example.js
const response = await fetch(
    'https://go.getblock.io/<ACCESS-TOKEN>/walletsolidity/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
import requests

response = requests.post(
    'https://go.getblock.io/<ACCESS-TOKEN>/walletsolidity/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

Response Parameters

Field
Type
Description

result.result

boolean

true when the call executed successfully

constant_result

array

ABI-encoded return data of the call, hex-encoded

energy_used

integer

Energy 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 Status
Message
Description

200

OK

The request succeeded; some TRON errors are returned in the 200 body as an Error field

400

Bad request

The request body is malformed or a required field is missing

500

Internal error

The node failed to process the request

Was this helpful?