Skip to content

RPC Support

Moonbeam v Ethereum - RPC Support Banner

Introduction

While Moonbeam strives to be compatible with Ethereum's Web3 API and EVM, there are some important Moonbeam differences that developers should know and understand in terms of the Ethereum API JSON-RPC support.

The Moonbeam team has collaborated closely with Parity on developing Frontier. Frontier is the Ethereum compatibility layer for Substrate based chains, and it is what allows developers to run unmodified Ethereum DApps.

Nevertheless, not all of the Ethereum JSON RPC methods are supported, and some of the supported ones return default values (those related to Ethereum's PoW consensus mechanism in particular). This guide will outline some of these main differences around Ethereum RPC support and what to expect when using Moonbeam for the first time.

Basic Ethereum JSON RPC Methods

At the time of writing, the basic JSON RPC methods from the Ethereum API supported by Moonbeam are:

  • eth_protocolVersion — Returns 1 by default
  • eth_syncing — Returns an object with data about the sync status or false
  • eth_hashrate — Returns "0x0" by default
  • eth_coinbase — Returns the latest block author. Not necessarily a finalized block
  • eth_mining — Returns false by default
  • eth_chainId — Returns the chain ID used for signing at the current block
  • eth_gasPrice — Returns the base fee per unit of gas used. This is currently the minimum gas price for each network
  • eth_accounts — Returns a list of addresses owned by the client
  • eth_blockNumber — Returns the highest available block number
  • eth_getBalance — Returns the balance of the given address
  • eth_getStorageAt — Returns content of the storage at a given address
  • eth_getBlockByHash — Returns information about the block of the given hash including baseFeePerGas on post-London blocks
  • eth_getBlockByNumber — Returns information about the block specified by block number including baseFeePerGas on post-London blocks
  • eth_getTransactionCount — Returns the number of transactions sent from the given address (nonce)
  • eth_getBlockTransactionCountByHash — Returns the number of transactions in a block with a given block hash
  • eth_getBlockTransactionCountByNumber — Returns the number of transactions in a block with a given block number
  • eth_getUncleCountByBlockHash — Returns "0x0" by default
  • eth_getUncleCountByBlockNumber — Returns "0x0" by default
  • eth_getCode — Returns the code at given address at given block number
  • eth_sendTransaction — Creates new message call transaction or a contract creation, if the data field contains code. Returns the transaction hash, or the zero hash if the transaction is not yet available
  • eth_sendRawTransaction — Creates new message call transaction or a contract creation for signed transactions. Returns the transaction hash, or the zero hash if the transaction is not yet available
  • eth_call — Executes a new message call immediately without creating a transaction on the block chain, returning the value of the executed call
  • eth_estimateGas — Returns an estimate amount of how much gas is necessary for a given transaction to succeed. You can optionally specify a gasPrice or maxFeePerGas and maxPriorityFeePerGas
  • eth_feeHistory — Returns baseFeePerGas, gasUsedRatio, oldestBlock, and reward for a specified range of up to 1024 blocks
  • eth_getTransactionByHash — Returns the information about a transaction with a given hash. EIP-1559 transactions have maxPriorityFeePerGas and maxFeePerGas fields
  • eth_getTransactionByBlockHashAndIndex — Returns information about a transaction at a given block hash, and a given index position. EIP-1559 transactions have maxPriorityFeePerGas and maxFeePerGas fields
  • eth_getTransactionByBlockNumberAndIndex — Returns information about a transaction at a given block number, and a given index position. EIP-1559 transactions have maxPriorityFeePerGas and maxFeePerGas fields
  • eth_getTransactionReceipt — Returns the transaction receipt of a given transaction hash. After London Support was added in Runtime 1200, a new field named effectiveGasPrice has been added to the receipt, specifying the gas price of the transaction
  • eth_getUncleByBlockHashAndIndex — Returns null by default
  • eth_getUncleByBlockNumberAndIndex — Returns null by default
  • eth_getLogs — Returns an array of all logs matching a given filter object
  • eth_getWork — Returns ["0x0","0x0","0x0"] by default
  • eth_submitWork — Not supported on Moonbeam
  • eth_submitHashrate — Not supported on Moonbeam

At the time of writing, the filter-related JSON RPC methods from the Ethereum API supported by Moonbeam are:

  • eth_newFilter — Creates a filter object based on the input provided. Returns a filter ID
  • eth_newBlockFilter — Creates a filter in the node to notify when a new block arrives. Returns a filter id
  • eth_newPendingTransactionFilter — Creates a filter in the node to notify when a new pending transaction arrives. Returns a filter ID
  • eth_getFilterChanges — Polling method for filters (see methods above). Returns an array of logs which occurred since last poll
  • eth_getFilterLogs — Returns an array of all the logs matching the filter with a given ID
  • eth_uninstallFilter — Uninstall a filter with a given ID. Should be used when polling is no longer needed. Filters timeout when they are not requested using eth_getFilterChanges after a period of time

Event Subscription Ethereum JSON RPC Methods

At the time of writing, the event subscription JSON RPC methods from the Ethereum API supported by Moonbeam are:

  • eth_subscribe — Creates a subscription for a given subscription name. If successful, returns the subscription ID
  • eth_unsubscribe — Cancels the subscription given by its ID

Supported Subscription

At the time of writing, the supported subscriptions are:

  • newHeads — Triggers a notification each time a new header is appended to the chain
  • logs — Returns logs that are included in new imported blocks, and match a given filter criteria
  • newPendingTransactions — Returns the hash for all transactions that are added to the pending state
  • syncing — Indicates when the node starts or stop synchronizing with the network

For a dedicated tutorial for these subscriptions checkout the Events Subscription guide.