Skip to main content

Services documentation

Use services provided by MetaMask and Infura to optimize essential development tasks and scale your dapp or Snap.

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

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

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": [],
"id": 1
}'