TriportRPC

eth_getCode

POSThttps://api.triport.io/polygon

Returns the compiled bytecode deployed at a Polygon address, or `0x` if the address is an externally-owned account (EOA) or holds no code.

Polygonpolygon_read_rpcfree — 15 rps · basic — 20 rps · pro — 100 rps · business — 250 rps (with burst)

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

Positional params array of exactly two elements.

addressstring (20-byte hex, 0x-prefixed)required
The address whose bytecode you want.
blockTagstringrequired
Block to read state at: a hex block number (e.g. 0x2A4B1C0), or one of the tags latest, earliest, pending, safe, finalized.

Response

For an EOA, a never-deployed address, or a contract self-destructed by the queried block, the result is empty bytecode:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x"
}
resultstring
0x-prefixed hex of the runtime bytecode at the address, or 0x when there is no code.

Errors

JSON-RPC requests return errors in the standard error object with a numeric code, a message, and a data payload carrying tier/rate-limit context.

CodeHTTP equiv.MeaningWhen it happens
-32001401trial_expiredThe key's trial period has ended.
-32002403tier_insufficientThe key's tier is below what the method requires. (eth_getCode itself only needs free tier.)
-32003429rate_limitedYou exceeded your tier's RPS + burst budget. See data.retry_after_sec.
-32004401subscription_expiredThe key's paid subscription has lapsed.
-32005401unauthorizedMissing, malformed, or invalid API key.
-32601403method_unknownThe method is not enabled for this key/chain.

Example rate-limit error:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32003,
    "message": "rate limit exceeded",
    "data": {
      "category": "polygon_read_rpc",
      "current_tier": "free",
      "limit_rps": 15,
      "retry_after_sec": 1,
      "method": "eth_getCode",
      "chain": "polygon"
    }
  }
}

See the shared errors reference for the full envelope and the HTTP ↔ JSON-RPC wire-code mapping.

Examples

JavaScript (fetch)

const res = await fetch("https://api.triport.io/polygon", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "eth_getCode",
    params: ["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", "latest"],
  }),
});


const { result } = await res.json();
const isContract = result !== "0x";
console.log(isContract ? "contract" : "EOA");

TypeScript SDK (@triport/sdk)

import { Triport } from "@triport/sdk";


const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });


const code = await client.polygon.rpc<string>("eth_getCode", [
  "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
  "latest",
]);


console.log(code === "0x" ? "EOA" : `contract, ${(code.length - 2) / 2} bytes`);

Python (triport-sdk)

import os
from triport import Triport


client = Triport(api_key=os.environ["TRIPORT_API_KEY"])


code = client.polygon.rpc(
    "eth_getCode",
    ["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", "latest"],
)


print("EOA" if code == "0x" else f"contract, {(len(code) - 2) // 2} bytes")

Notes

  • EOA vs. contract: treat any non-0x result as a contract. Do not assume a fixed length — proxy shims are tens of bytes while large contracts (e.g. Aave V3 pools) approach the ~24 KB EIP-170 runtime limit.
  • Proxy detection: eth_getCode alone cannot see through a proxy. Read the EIP-1967 implementation slot with eth_getStorageAt, then re-query the resolved address.
  • Payload size: the response scales with bytecode size. For large contracts the body can be several tens of KB — budget for that when polling many addresses.
  • Historical reads: pass a hex block number as blockTag to inspect code at a past block (useful for confirming a deployment block). Archive depth varies by tier.
  • Related methods: eth_getStorageAt, eth_call, eth_getBalance.