/wallet/getcontract - Tron

This endpoint returns the metadata and ABI of a smart contract deployed at an address.

Parameters

ParameterTypeRequiredDescription
valuestringYesThe contract address
visiblebooleanNoAccept and return addresses in base58 format

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/wallet/getcontract' \
--header 'Content-Type: application/json' \
--data-raw '{
  "value": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
  "visible": true
}'

example.js

javascriptconst response = await fetch(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/wallet/getcontract',
    {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({"value": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "visible": true})
    }
);
console.log(await response.json());

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/wallet/getcontract',
    headers={'Content-Type': 'application/json'},
    json={"value": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "visible": true}
)

print(response.json())

Response

json{
  "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
  "origin_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
  "abi": {
    "entrys": [
      {
        "name": "transfer",
        "type": "Function"
      }
    ]
  },
  "name": "TetherToken",
  "consume_user_resource_percent": 100,
  "origin_energy_limit": 10000000
}

Response Parameters

FieldTypeDescription
contract_addressstringThe contract address
origin_addressstringThe deployer address
abiobjectThe contract ABI, when available
namestringThe contract name
consume_user_resource_percentintegerShare of Energy paid by the caller

Use Cases

  • ABI Retrieval: Read a contract's ABI to encode calls
  • Contract Inspection: Read a contract's name and deployer
  • Energy Policy: Read the caller's Energy share for the contract
  • Verification: Confirm a contract exists at an address

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