curl --request POST \
--url https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300 \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"id": 1,
"params": [
"0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
"latest"
]
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
curl --request POST \
--url https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300 \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"id": 1,
"params": [
"0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
"latest"
]
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
eth_getCode
retrieves the code stored at a specific address. This method is typically used to inspect the bytecode of smart contracts on the Optimism blockchain.
This example retrieves the bytecode of the Chainlink token on the Optimism Mainnet.
address
— the address to get the code from.block
— the block number (in hexadecimal) or one of the strings "earliest"
, "latest"
, or "pending"
, indicating the state to consider. The default is "latest"
.result
— the code from the specified address, returned as a hexadecimal string.eth_getCode
method is essential for:
The code from the specified address
The response is of type object
.
Was this page helpful?