MPP.Methods.EVM.RPC (mpp v0.20.1)

Copy Markdown View Source

Shared EVM JSON-RPC helpers used by hash, authorization, and transaction paths.

Summary

Functions

Normalize a 0x-prefixed transaction hash to lowercase.

Require a non-negative integer chain_id in method config.

Build Onchain.RPC options from an RPC URL and optional Req overrides.

Fetch a transaction's recipient and value by hash (eth_getTransactionByHash).

Functions

canonicalize_hash(hash)

@spec canonicalize_hash(String.t()) :: String.t()

Normalize a 0x-prefixed transaction hash to lowercase.

require_chain_id(config)

@spec require_chain_id(map()) :: {:ok, non_neg_integer()} | {:error, MPP.Errors.t()}

Require a non-negative integer chain_id in method config.

rpc_opts(rpc_url, config)

@spec rpc_opts(String.t(), map()) :: keyword()

Build Onchain.RPC options from an RPC URL and optional Req overrides.

transaction_by_hash(hash, opts)

@spec transaction_by_hash(String.t(), keyword()) ::
  {:ok, %{to: binary() | nil, value: non_neg_integer()} | nil}
  | {:error, term()}

Fetch a transaction's recipient and value by hash (eth_getTransactionByHash).

Reads only to and value from the raw result rather than decoding a full Ethereum signing envelope, so chain-specific transaction types (OP Stack deposits, zkSync, Celo) still verify. Both fields are validated strictly: to is nil or a 20-byte address, value a hex quantity. An unknown hash is {:ok, nil}.