eth_getCode
Extracts the compiled bytecode of smart contracts deployed on the Polygon PoS (Proof of Stake) network. This method is essential for DeFi protocol analysis, contract verification, and Web3 development on Polygon's high-performance, low-cost EVM-compatible blockchain.
Parameters​
Parameter | Type | Required | Description |
---|---|---|---|
address | string | Yes | The 20-byte contract address (0x-prefixed hex string) |
blockNumber/blockTag | string | Yes | Block number in hex (e.g., "0x1b4") or block tag: "latest", "earliest", "pending", "safe", "finalized" |
Block Tags​
latest
- Most recent block in the canonical chainearliest
- Genesis blockpending
- Pending state/transactionssafe
- Latest safe head block (Polygon)finalized
- Latest finalized block (Polygon)
Returns​
Returns the contract bytecode as a hex-encoded string. Externally Owned Accounts (EOAs) return "0x".
Type | Description |
---|---|
string | Hex-encoded contract bytecode starting with "0x". Returns "0x" for EOA addresses |
Code Examples​
- cURL
- JavaScript
- Python
# Get bytecode for USDC contract on Polygon
curl -X POST https://api-polygon-mainnet-full.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"latest"
],
"id": 1
}'
// Get bytecode for Aave V3 Pool on Polygon
const response = await fetch('https://api-polygon-mainnet-full.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getCode',
params: [
'0x794a61358D6845594F94dc1DB02A252b5b4814aD',
'latest'
],
id: 1
})
});
const data = await response.json();
console.log('Aave Pool bytecode:', data.result);
// Analyze contract type
if (data.result === '0x') {
console.log('Address is an EOA (no contract)');
} else {
const bytecodeSize = (data.result.length - 2) / 2;
console.log(`Contract deployed with ${bytecodeSize} bytes`);
// Check for common patterns
if (data.result.includes('1901')) {
console.log('EIP-712 domain separator detected');
}
}
import requests
import json
# Get bytecode for QuickSwap Router on Polygon
url = "https://api-polygon-mainnet-full.n.dwellir.com/YOUR_API_KEY"
payload = {
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", # QuickSwap Router
"latest"
],
"id": 1
}
response = requests.post(url, json=payload)
result = response.json()
if result['result'] == '0x':
print("Address is an EOA")
else:
bytecode = result['result']
print(f"QuickSwap Router bytecode: {bytecode[:100]}...")
print(f"Contract size: {(len(bytecode) - 2) // 2} bytes")
# Analyze for known patterns
if "5af43d82803e903d91602b57fd5bf3" in bytecode:
print("Detected: CREATE2 factory pattern")
elif "3d602d80600a3d3981f3363d3d373d3d3d363d73" in bytecode:
print("Detected: Minimal proxy (EIP-1167)")
else:
print("Standard contract deployment")
Response Example​
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x6080604052348015600f57600080fd5b506004361061004a5760003560e01c80630dbe671f1461004f5780634aa4a4fc14610081578063ad5c4648146100a5578063d0e30db0146100c9575b600080fd5b34801561005b57600080fd5b50610064610100565b604051808267ffffffffffffffff1681526020019150506040518091039082f35b34801561008d57600080fd5b50610096610124565b60405180821515815260200191505060405180910390f35b3480156100b157600080fd5b506100ba610134565b60405180821515815260200191505060405180910390f35b6100fe600480360360208110156100e057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610144565b005b60006101246040518060400160405280600f81526020017f48656c6c6f2c20506f6c79676f6e210000000000000000000000000000000000815250610200565b905090565b6000600160009054906101000a900460ff16905090565b6000600260009054906101000a900460ff16905090565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156101e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806102266026913960400191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60608160405160200180828051906020019080838360005b8381101561023357808201518184015260208101905061021857906102b1565b50505050905090810190601f1680156102605780820380516001836020036101000a031916815260200191505b509250505060405160208183030381529060405290509056fe496e76616c696420616464726573732070726f766964656400000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8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f064736f6c634300060c0033"
}
Important Notes​
EOA vs Contract Addresses​
- Contract addresses: Return the deployed smart contract bytecode
- EOA addresses: Return "0x" as they contain no executable code
- Critical for distinguishing between user wallets and smart contracts
Use Cases​
- DeFi protocol analysis: Examine yield farming and liquidity mining contracts
- NFT marketplace verification: Validate OpenSea and other marketplace contracts
- Gaming contract analysis: Analyze play-to-earn and NFT gaming contracts
- Cross-chain bridge verification: Examine bridge contract implementations
Polygon-Specific Considerations​
- Polygon PoS uses a sidechain architecture with Ethereum compatibility
- Extremely low transaction costs enable micro-transaction use cases
- Full EVM compatibility ensures seamless Ethereum contract deployment
- Native MATIC token integration for gas fees and staking rewards
Need help? Contact our support team or check the Polygon documentation.