eth_getCode - Monad
Example code for the eth_getCode JSON-RPC method. Complete guide on how to use eth_getCode JSON-RPC in GetBlock Web3 documentation.
This method returns code at a given address. Used to verify if an address is a smart contract.
Parameters
address
string
Yes
The address to get the code from.
blockNumber
string
No
Block number in hex, or "latest", "earliest", "pending", "safe", "finalized".
Request examples
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0x55962b6c47ae83427d02bcb9832adef4ece7bbf6", "latest"],
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0x55962b6c47ae83427d02bcb9832adef4ece7bbf6", "latest"],
"id": "getblock.io"
});
const config = {
method: 'post',
url: 'https://go.getblock.io/<ACCESS-TOKEN>/',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data)))
.catch(error => console.log(error));Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x606060405260043610610062576000357c0100..."
}Response Parameters
result
string
The bytecode at the address. Returns "0x" for EOAs (externally owned accounts).
Use Case
The eth_getCode method is essential for:
Verifying if an address is a contract
Security checks before interactions
Contract bytecode analysis
Detecting proxy contracts
Block explorer functionality
Smart contract verification
Error Handling
403
Forbidden
Missing or invalid ACCESS-TOKEN.
-32602
Invalid params
Invalid address format.
-32000
Resource not found
Block not found.
Web3 Integration
Last updated
Was this helpful?