Skip to content

debug_codeByHash ​

served · same as reth

Returns the bytecode that has a given code hash.

When to use ​

Use it when you have the codeHash of an account, for example from eth_getProof, and need the code.

Example ​

bash
curl -s -X POST -H 'Content-Type: application/json' \
  --data '{"jsonrpc": "2.0", "id": 1, "method": "debug_codeByHash", "params": ["0xd0a06b12ac47863b5c7be4185c2deaad1c61557033f56c7d4ea74429cbb25e23"]}' \
  http://127.0.0.1:8547
json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "debug_codeByHash",
  "params": [
    "0xd0a06b12ac47863b5c7be4185c2deaad1c61557033f56c7d4ea74429cbb25e23"
  ]
}

Response ​

Live mainnet, 2026-10-14. Checked against reth 2.7: equal.

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b9578063095ea7b31461014757806318160ddd146101a157806323b872dd146101ca5780632e1a7d4d14610243578063313ce5671461026657806370a082311461029557806395d89b41146102e2578063a9059cbb14610370578063d0e30db0146103ca578063dd62ed3e146103d4575b6100b7610440565b005b34156100c457600080fd5b6100... 5850 more characters"
}

Full response

Parameters ​

NameTypeRequiredMeaning
codeHash32-byte hashyesThe keccak256 hash of the code.
blockblock number in hex, or a tag, see Block parameternoThe block. The head or one of the 128 blocks before it. Default: latest.

Returns ​

The code as hex data, or null when the node does not have code with this hash.

Errors ​

CodeMessageWhen
-32602Invalid paramsA parameter is missing or does not parse. data has the text of reth, with the position.

Compared with reth ​

The live example above gives the same answer on Cinder and on reth 2.7.

eth_getCode, eth_getAccount.

Schema (OpenRPC) ​

Parameter codeHash: Hash32
json
{
  "title": "32 byte hex value",
  "type": "string",
  "pattern": "^0x[0-9a-f]{64}$"
}
Parameter block: BlockSelector
json
{
  "title": "Block number, tag or block identifier",
  "description": "A block number, a tag, or an object with blockHash or blockNumber. Null means latest.",
  "oneOf": [
    {
      "title": "hex encoded unsigned integer",
      "type": "string",
      "pattern": "^0x(0|[1-9a-f][0-9a-f]*)$"
    },
    {
      "title": "Block tag",
      "type": "string",
      "enum": [
        "earliest",
        "finalized",
        "safe",
        "latest",
        "pending"
      ],
      "description": "latest is the head of the last forkchoice update, as reth. pending is the block that Cinder builds from its transaction pool after latest, as reth. safe and finalized are the blocks of the last forkchoice update, as reth. Before the first update, they name no block. earliest is the first block that the node stored, as reth."
    },
    {
      "type": "object",
      "properties": {
        "blockHash": {
          "title": "32 byte hex value",
          "type": "string",
          "pattern": "^0x[0-9a-f]{64}$"
        },
        "blockNumber": {
          "title": "hex encoded unsigned integer",
          "type": "string",
          "pattern": "^0x(0|[1-9a-f][0-9a-f]*)$"
        }
      },
      "additionalProperties": false
    },
    {
      "type": "null"
    }
  ]
}
Result: Bytes or null
json
{
  "oneOf": [
    {
      "title": "hex encoded bytes",
      "type": "string",
      "pattern": "^0x[0-9a-f]*$"
    },
    {
      "type": "null"
    }
  ]
}