eth_getCode
POST
https://triport.io/rpc/tronReturns the bytecode stored at an EVM address in the current Tron state.
Tron mainnettron:rpcfree+; tron_read_rpc: 15 / 20 / 100 / 250 RPS (free / basic / pro / business; default, unmeasured)
eth_getCode returns the byte sequence stored as contract code at a 20-byte EVM
address. The result uses EVM data encoding: 0x followed by an even number of
hexadecimal characters. 0x represents an empty byte sequence.
The state read is available only at latest; historical block quantities are
not accepted. Use this method to distinguish deployed bytecode from an empty
address. Native contract metadata is available from
getcontractinfo.
Parameters
JSON-RPC params is [address, block].
addressstringrequired0x-prefixed 20-byte EVM address.blockstringrequiredMust be
latest; historical quantities are unsupported.Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC protocol version. |
id | number | Correlates the response with the request. |
result | string | Contract code as 0x-prefixed EVM data. |
Errors
See Tron errors for the common envelope.
| Code | Meaning | When it happens |
|---|---|---|
-32602 | Invalid params | The address is malformed or the block tag is not latest. |
-32601 | Method not found | The method is outside the published catalog. |
401 | Unauthorized | The API key is missing or invalid. |
429 | Rate limited | The tron_read_rpc budget is exceeded. |
Examples
const params = ["0xa614f803b6fd780986a42c78ec9c7f77e6ded13c", "latest"];
const response = await fetch("https://triport.io/rpc/tron", {
method: "POST",
headers: { "x-token": process.env.TRIPORT_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_getCode", params }),
});
const { result: code } = await response.json();Notes
0xis an empty data value; the schema does not assign a separate null case.- Historical EVM code is unavailable because only the
lateststate tag is supported. - Related:
eth_getStorageAtandgetcontractinfo.