/wallet/getcontract¶
Get contract metadata by contract address. Returns the SmartContract itself (including the deploy-time bytecode), but not the runtime code (runtimecode) or contract_state. For runtime info, use /wallet/getcontractinfo.
- Source:
framework/src/main/java/org/tron/core/services/http/GetContractServlet.java - Method:
GET/POST - Response:
protocol.SmartContract(smart_contract.proto)
Request parameters¶
| Field | Type | Required | Description |
|---|---|---|---|
value |
string | Yes | Contract address |
visible |
bool | No | Address format (name is a proto string and is not affected by visible) |
Example:
curl --request POST \
--url https://nile.trongrid.io/wallet/getcontract \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"value": "41eca9bc828a3005b9a3b909f2cc5c2a54794de05f"
}
'
Response¶
| Field | Type | Description |
|---|---|---|
origin_address |
string | Deployer address |
contract_address |
string | Contract address |
abi |
ABI | Contract ABI |
bytecode |
string(hex) | Deployment bytecode (creation bytecode + constructor arguments concatenated, identical to what was passed at deploy time; not runtime code — see /wallet/getcontractinfo) |
call_value |
int64 | TRX sent with deployment |
consume_user_resource_percent |
int64 | Caller-paid energy percentage |
name |
string | Contract name |
origin_energy_limit |
int64 | Deployer's energy limit |
code_hash |
string(hex) | Bytecode hash |
trx_hash |
string(hex) | Deployment transaction hash |
version |
int32 | Version |
Proto default values are not serialized:
call_value=0,consume_user_resource_percent=0,version=0, and emptytrx_hashare omitted from the response.
Response example (Nile TetherToken):
{
"origin_address": "4165fa68800fff5a10346d1a3aa1fb2ce92f2e2971",
"contract_address": "41eca9bc828a3005b9a3b909f2cc5c2a54794de05f",
"abi": {
"entrys": [
{
"outputs": [{ "type": "string" }],
"constant": true,
"name": "name",
"stateMutability": "View",
"type": "Function"
}
]
},
"bytecode": "60806040526000600260146101000a81548160ff02191690831515021790555060...",
"name": "TetherToken",
"origin_energy_limit": 1000000000,
"code_hash": "1c32379f645df32d2a8e45de37319983d01d47185588337985aeefb4672a91f2"
}
Returns {} if not found.
Error responses¶
| Trigger | Response |
|---|---|
Request body exceeds node.maxMessageSize (POST) |
{"Error": "class java.lang.Exception : body size is too big, the limit is <N>"} |
value is not valid base58check (visible=true) |
If it contains non-base58 characters: {"Error": "class java.lang.IllegalArgumentException : <details>"}. If only the checksum is wrong, Util.getHexAddress silently returns an empty string → contract is not found and {} is returned. |
value is not valid hex (visible=false) |
{"Error": "class org.tron.core.services.http.JsonFormat$ParseException : <details>"} |
| Request body is not valid JSON (POST) | {"Error": "class com.alibaba.fastjson.JSONException : <parser info>"} |
| Other exceptions | {"Error": "<exceptionClass> : <message>"} |