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 PoW). 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:

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 occured 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 not 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 subcriptions 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.