Skip to content

[docs-agent] Add eth_getCodeByHash, eth_getHeaderByHash, eth_getHeaderByNumber method definitions for MegaETH#1458

Merged
dslovinsky merged 2 commits into
mainfrom
docs/megaeth-getcodebyhash-getheaderby-methods
Jul 17, 2026
Merged

[docs-agent] Add eth_getCodeByHash, eth_getHeaderByHash, eth_getHeaderByNumber method definitions for MegaETH#1458
dslovinsky merged 2 commits into
mainfrom
docs/megaeth-getcodebyhash-getheaderby-methods

Conversation

@alchemy-bot

Copy link
Copy Markdown
Contributor

Summary

Adds three new JSON-RPC method definitions to the custom method group and wires them into MegaETH:

  1. eth_getCodeByHash — resolves contract bytecode by keccak256 code-hash (params: codeHash: hash32 → result: bytes).
  2. eth_getHeaderByHash — returns the block header (no body-level fields) identified by blockHash: hash32.
  3. eth_getHeaderByNumber — same, identified by BlockNumberOrTag.

All three schemas were verified live against https://mainnet.megaeth.com/rpc (block 0x14855a6), and both header methods return the same header-shape object minus size, transactions, uncles, withdrawals compared to eth_getBlockByHash/ByNumber. Both return null for unknown blocks and -32602 Invalid params for missing/malformed parameters.

Sources

  • eth_getCodeByHash — MegaETH's stateless-validator docs explicitly reference this method (metric stateless_validator_code_fetch_time_seconds = "Per-call eth_getCodeByHash latency"; --data-max-concurrent-requests covers eth_get* "blocks, headers, code, tx"). Verified: keccak256 of the OP-style proxy bytecode at 0x4200...0011 (0xfa8c9db6...) resolves via eth_getCodeByHash and returns the same bytecode as eth_getCode; unknown hashes return "0x".
  • eth_getHeaderByHash / eth_getHeaderByNumber — Standard go-ethereum backend methods (HeaderByHash / HeaderByNumber) exposed as JSON-RPC by several EVM chains (Kaia, Somnia). MegaETH's stateless validation quickstart uses eth_getHeaderByNumber as the canonical way to fetch a trusted anchor header. All five block tags (earliest, latest, safe, finalized, pending) return valid headers on MegaETH mainnet.

New BlockHeader schema

Adds a BlockHeader schema to _components/custom/components.yaml (scoped to the custom group since these methods are MegaETH-specific for now). It mirrors the Block schema in _components/evm/block.yaml minus the body-level fields, plus requestsHash (EIP-7685, Pectra) which is present in MegaETH mainnet responses.

Daikon safety

Added the three new methods to x-bot-ignore in chains/megaeth/megaeth.yaml to prevent Daikon's daily chain-config sync from stripping them before the corresponding chain-config entries land upstream. Once Daikon manages these methods, the x-bot-ignore entries should be removed (see LEARNINGS.md → "Daikon x-bot-ignore sequencing trap").

Open questions

  • x-compute-units — set to 20 for all three (matches eth_getCode, eth_getBlockByHash, eth_getBlockByNumber), but the authoritative CU costs live in OMGWINNING/chain-config/topconfig.yml. Please confirm the CU values and adjust before merge.
  • Testnet coverage — all live verification was done against mainnet.megaeth.com/rpc. The spec lists both mainnet and testnet servers; assumed both endpoints support these methods (typical for MegaETH's public RPC parity), but please confirm.

Linear

DOCS-144 — https://linear.app/alchemyapi/issue/DOCS-144/add-eth-getcodebyhash-eth-getheaderbyhash-eth-getheaderbynumber-method

Requested by

@dslovinsky (via Slack thread)

…rByNumber method definitions for MegaETH

Adds three new MegaETH-supported JSON-RPC method definitions to the custom method group and wires them into chains/megaeth/megaeth.yaml. Schemas verified live against https://mainnet.megaeth.com/rpc; see DOCS-144 for source citations.

Refs DOCS-144

Requested-by: @dslovinsky
@alchemy-bot
alchemy-bot requested a review from a team as a code owner July 17, 2026 19:42
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

🔗 Preview Mode

Name Status Preview Updated (UTC)
Alchemy Docs ✅ Ready 🔗 Visit Preview Jul 17, 2026, 8:04 PM

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc4f1a2fa9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/openrpc/chains/_components/custom/methods.yaml Outdated
…example; revert megaeth.yaml wiring

Codex flagged that the eth_getCodeByHash example result was a truncated bytecode prefix, so users running the example receive a longer response than documented. Replaced with the complete bytecode returned by the live API for the referenced code hash.

Also reverted the chains/megaeth/megaeth.yaml $ref additions and x-bot-ignore updates per requester (those will be wired in a separate change, presumably via chain-config/Daikon).

Refs DOCS-144

Requested-by: @dslovinsky
@dslovinsky
dslovinsky merged commit 1b1a17b into main Jul 17, 2026
12 of 15 checks passed
@dslovinsky
dslovinsky deleted the docs/megaeth-getcodebyhash-getheaderby-methods branch July 17, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants