Skip to main content

eth_getCode

Returns the bytecode at a given address on Astar.

Why Astar? Build on Polkadot's leading dApp hub supporting EVM, WASM, and upcoming PolkaVM environments with EVM + WASM + PolkaVM support, Build2Earn developer rewards, dApp Staking, and Soneium cross-layer integration.

Use Cases#

The eth_getCode method is essential for:

  • Contract verification - Check if address is a contract
  • Security analysis - Verify deployed bytecode matches expected
  • DeFi integrations - Validate contracts before interactions
  • Protocol analysis - Analyze contract deployments for cross-chain DeFi, multi-VM smart contracts, and XCM-enabled interoperability with Ethereum and Cosmos

Parameters#

ParameterTypeRequiredDescription
addressDATAYes20-byte address
blockParameterQUANTITY|TAGYesBlock number or tag

Request#

{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
"latest"
],
"id": 1
}

Returns#

TypeDescription
DATAContract bytecode or 0x if EOA

Code Examples#

curl -X POST https://api-astar.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
"latest"
],
"id": 1
}'