This method returns the deployed bytecode at a specific address, hex-encoded. For contract addresses it returns the runtime bytecode; for EOAs it returns 0x. Post-Pectra (EIP-7702) EOAs can temporarily delegate to smart-contract code, in which case this returns the delegated code marker (0xef0100 + implementation address).
bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"latest"
],
"id": "getblock.io"
}'
javascriptconst axios = require('axios');
const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_getCode',
params: [
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"latest"
],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
console.log(response.data.result);
pythonimport requests
response = requests.post(
'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
headers={'Content-Type': 'application/json'},
json={
'jsonrpc': '2.0',
'method': 'eth_getCode',
'params': [
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"latest"
],
'id': 'getblock.io'
}
)
print(response.json())
rustuse reqwest::Client;
use serde_json::{json, Value};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
const response = client
.post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
.header("Content-Type", "application/json")
.json(&json!({
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"latest"
],
"id": "getblock.io"
}))
.send()
.await?
.json::<Value>()
.await?;
println!("Result: {}", response["result"]);
Ok(())
}
javascriptimport { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');
const code = await provider.getCode('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2');
if (code === '0x') {
console.log('EOA (no contract code)');
} else if (code.startsWith('0xef0100')) {
// EIP-7702: EOA has delegated to a smart contract
const delegateAddr = '0x' + code.slice(8);
console.log('EIP-7702 delegated EOA — delegate:', delegateAddr);
} else {
console.log('Contract, bytecode length:', (code.length - 2) / 2, 'bytes');
}
javascriptimport { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
const client = createPublicClient({
chain: mainnet,
transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/'),
});
const code = await client.getCode({ address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' });
if (!code || code === '0x') {
console.log('EOA (no contract code)');
} else if (code.startsWith('0xef0100')) {
const delegateAddr = '0x' + code.slice(8);
console.log('EIP-7702 delegated EOA — delegate:', delegateAddr);
} else {
console.log('Contract, bytecode length:', (code.length - 2) / 2, 'bytes');
}