TriportRPC

eth_getCode

Polygon / https://triport.io/polygon

Minimum tier: Free

Polygon method guide

Last updated:

eth_getCode returns the bytecode stored at a given address as of a given block. For a contract account it returns the runtime (deployed) bytecode; for an externally-owned account, a non-existent address, or a contract that has self-destructed at the queried block, it returns 0x.

Use it to tell whether an address is a contract or an EOA, to fingerprint a deployment, or to confirm that a contract was already deployed at a historical block. The result is the runtime bytecode, not the constructor/creation bytecode, so it will not match the data field of the deployment transaction.

Polygon hosts a large number of proxy contracts — bridged USDC.e and many other tokens are upgradeable proxies. For those, eth_getCode returns the small proxy shim, not the logic contract. To resolve the implementation behind an EIP-1967 proxy, pair this call with eth_getStorageAt reading the implementation slot 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, then call eth_getCode again on the address stored there.

This method is available on the free tier under the polygon_read_rpc category, so any valid key can call it.

Parameters

This method takes no parameters.

Returns

eth_getCode return value
FieldType
resultobject

Examples

curl https://triport.io/polygon \
  -X POST -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <api-key>' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getCode","params":[]}'
const res = await fetch("https://triport.io/polygon", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
  body: JSON.stringify({
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getCode",
  "params": []
}),
});
const data = await res.json();
import requests
resp = requests.post(
    "https://triport.io/polygon",
    headers={"Authorization": "Bearer <api-key>"},
    json={"jsonrpc":"2.0","id":1,"method":"eth_getCode","params":[]},
)
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Chain: Polygon.
  3. Clusters: mainnet.
  4. Credit cost: 1 per call.

FAQ

What does eth_getCode do?
Returns the compiled bytecode deployed at a Polygon address, or 0x if the address is an externally-owned account (EOA) or holds no code.
How many credits does eth_getCode cost?
eth_getCode costs 1 credit(s) per call on Triport by default.
Is eth_getCode available over WebSocket?
eth_getCode is an HTTP JSON-RPC method.