Skip to content

feat(eth-rpc): enhance MetaMask & Web3.js compatibility with complete JSON-RPC and WebSocket support - #4099

Open
D-H-O-R-A wants to merge 1 commit into
wavesplatform:version-1.6.xfrom
D-H-O-R-A:fix/metamask-web3-jsonrpc-compat
Open

D-H-O-R-A wants to merge 1 commit into
wavesplatform:version-1.6.xfrom
D-H-O-R-A:fix/metamask-web3-jsonrpc-compat

Conversation

@D-H-O-R-A

Copy link
Copy Markdown

Summary of Changes

This Pull Request addresses several compatibility issues encountered when connecting MetaMask, ethers.js, and web3.js directly to the Waves Node EVM JSON-RPC endpoint.

Problems Identified & Solved

  1. Missing Essential JSON-RPC Methods for Web3 / MetaMask:

    • net_version: Expected by MetaMask to return the chain ID in decimal representation string.
    • eth_protocolVersion: Returns standard protocol version (0x41).
    • eth_syncing: Returns boolean false or synchronization state.
    • eth_getTransactionReceipt: Returns full transaction status (0x1 / 0x0), cumulative gas, effective gas price, and block metadata expected by Web3 wallets.
    • eth_getCode: Distinguishes between EOA and accounts with RIDE contracts/dApps.
    • eth_getLogs: Standard event log filtering.
    • eth_getStorageAt: Direct access to account data storage state.
    • personal_ecRecover: Recovers Ethereum public keys/addresses from standard prefixed signed messages.
    • eth_uncleCountByBlockHash, eth_uncleCountByBlockNumber, eth_getUncleBy...: Returns empty/null for PoS consensus.
  2. WebSocket Support for Subscriptions:

    • Added Akka HTTP WebSocket flow on /eth/ws and /ws allowing wallets and frontends to subscribe to newHeads and logs.
  3. Virtual ERC-20 & ERC-721 Metadata via eth_call:

    • Decodes standard ABI calls (name(), symbol(), decimals(), totalSupply(), balanceOf(address), tokenURI(uint256), ownerOf(uint256)) for native assets and NFTs so that MetaMask and Web3 explorers can render token names, icons, and balances seamlessly.
  4. EthereumTransaction Timestamp Validation Tolerance:

    • In CommonValidation.scala, relaxed timestamp mistiming checks for EthereumTransaction when timestamps originate from standard EVM clients.
  5. Unit Tests:

    • Comprehensive test cases added to EthRpcRouteSpec.scala covering all added RPC methods and token metadata interactions.

…SON-RPC/WSS support

- Add standard MetaMask RPC methods: net_version, eth_protocolVersion, eth_getTransactionReceipt, eth_getCode, eth_syncing, eth_getLogs, personal_ecRecover
- Add WebSocket support for JSON-RPC and subscription management
- Add virtual ERC-20 and ERC-721 token metadata and interfaces for eth_call
- Handle EthereumTransaction timestamp offset tolerance in CommonValidation
- Add comprehensive unit tests in EthRpcRouteSpec
@D-H-O-R-A
D-H-O-R-A requested a review from phearnot as a code owner October 23, 2026 00:34

This branch has not been deployed

No deployments
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.

1 participant