Skip to main content
EVM
Archive

eth_getCode

Summary: Get smart contract code

This request returns the compiled byte code of a smart contract, if any, at a given address and block.

Parameters

address string
required

Hex-encoded address.

Pattern: ^0x[0-9a-fA-F]{40}$


block anyOf
required

Block number, block hash, or string tag.

Block number string

Block number in hexadecimal.

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Block tag enum

See the default block parameter.

  • earliest: The lowest numbered block the client has available.
  • finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination.
  • latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions.
  • pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from local mempool.

Enum:
"earliest"
"finalized"
"latest"
"pending"
Block hash string

32 byte hex value.

Pattern: ^0x[0-9a-f]{64}$

Returns

The compiled byte code of the smart contract at the given address. Linea stores compiled smart contract code as a hexadecimal value.
eth_getCodeResponse string

The compiled byte code of the smart contract at the given address. Linea stores compiled smart contract code as a hexadecimal value.

Pattern: ^0x[0-9a-f]*$

Customize request
Parameter
Value
string
0x927cf4
anyOf
Request
curl https://linea-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f","0x927cf4"],
"id": 1
}'
Example response
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x6060604052600436106100af576000357c01000000000...."
}