eth_getCode
Last updated:
`eth_getCode` returns the compiled EVM bytecode deployed at an address, as a `0x`-prefixed hex string, as of a specific block. This is the code that actually runs when the contract is called — not the source, the ABI, or the constructor ("init") code, but the runtime bytecode persisted on chain.
Use it to tell a contract apart from an externally-owned account (EOA), to fetch the on-chain bytecode for verification or disassembly, or to confirm that a deployment landed at the expected address before you start calling it.
The key behaviour to plan for: **an empty result is `0x`.** A plain wallet (EOA), an address that has never been deployed to, and a contract that hasn't been deployed *yet at the queried block* all return `0x`. Code presence is therefore the reliable "is this a contract?" check — `result !== "0x"` means bytecode exists at that address at that block.
Parameters
This method takes no parameters.
Returns
| Field | Type |
|---|---|
| result | object |
Examples
curl https://<your-endpoint>/ \
-X POST -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_getCode","params":[]}'const res = await fetch("https://<your-endpoint>/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"id": 1,
"method": "eth_getCode",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"eth_getCode","params":[],"jsonrpc":"2.0"})
print(resp.json())Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet.
- Credit cost: 1 per call.
FAQ
- What does eth_getCode do?
- Returns the deployed bytecode stored at an address at a given block.
- 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.