Logo

What is a Moonbeam RPC and how do you use it?

Key Takeaways

  • Moonbeam RPC endpoints allow Ethereum-compatible wallets and dApps to interact with the Moonbeam parachain.
  • Moonbeam uses standard Ethereum JSON-RPC methods plus custom methods for its unique features.
  • Public RPC endpoints are available but may have rate limits and reliability issues for production use.
  • Dedicated node providers offer higher throughput, lower latency, and better support for production dApps.
  • When choosing a provider, consider request limits, geographic distribution, and API method support.
  • Moonbeam's chain ID is 1284 and its native token is GLMR.
  • WebSocket endpoints are essential for real-time data like event subscriptions.

What is a Moonbeam RPC endpoint?

A Moonbeam RPC endpoint is a URL that allows external applications to communicate with the Moonbeam blockchain via JSON-RPC. Since Moonbeam is fully Ethereum-compatible, it supports standard Ethereum JSON-RPC methods like `eth_call`, `eth_sendTransaction`, and `eth_getLogs`, as well as custom methods for Moonbeam-specific features such as on-chain governance and cross-chain messaging.

Developers use these endpoints to deploy smart contracts, query on-chain data, send transactions, and subscribe to events. RPC endpoints are the backbone of any Web3 application interacting with Moonbeam.

  • Standard Ethereum JSON-RPC methods work out of the box.
  • Custom Moonbeam methods provide access to parachain-specific functionality.
  • Both HTTP and WebSocket endpoints are available.

Moonbeam network specifications

Before connecting to Moonbeam, you need the correct network parameters. Moonbeam Mainnet uses chain ID 1284 and the native token GLMR. The block explorer is Moonscan (https://moonscan.io).

For development and testing, Moonbeam also provides a TestNet (Moonbase Alpha) with chain ID 1287 and token DEV.

CriterionWhat to checkWhy it matters
Network NameMoonbeam MainnetIdentifies the network in wallets and dApps.
Chain ID1284 (0x504)Required for transaction signing and network identification.
Native TokenGLMRUsed for gas fees and staking.
Block Explorerhttps://moonscan.ioFor verifying transactions and contract interactions.
RPC Endpoint Examplehttps://moonbeam.api.onfinality.io/publicPublic endpoint for initial testing.

How to find Moonbeam RPC endpoints

There are several ways to obtain a Moonbeam RPC endpoint. Public endpoints are available for free but often have rate limits and may not be suitable for production. For reliable access, consider using a managed RPC provider that offers dedicated or shared nodes with guaranteed performance.

OnFinality provides both public and private Moonbeam RPC endpoints. The public endpoint is a good starting point for development, while dedicated nodes offer higher throughput and lower latency for production applications.

  • Public RPC endpoints: Free but limited in requests per second and uptime guarantees.
  • Shared private endpoints: Higher rate limits and better reliability for moderate usage.
  • Dedicated nodes: Full control, unlimited requests, and custom configuration for high-demand projects.

Choosing a Moonbeam RPC provider

When selecting a provider for your Moonbeam RPC needs, consider factors like request throughput, geographic distribution, API method support (including trace and debug APIs), and pricing model. For production dApps, uptime and latency are critical.

OnFinality offers Moonbeam RPC endpoints with global load balancing, support for standard and custom JSON-RPC methods, and flexible pricing. You can start with a free tier and scale up as your project grows.

  • Evaluate request per second (RPS) limits and whether they match your traffic.
  • Check if the provider supports WebSocket for real-time subscriptions.
  • Look for providers with multiple data center locations for redundancy.
  • Consider whether you need trace or debug APIs for advanced debugging.

How to connect to Moonbeam RPC

Connecting to Moonbeam is straightforward. In a wallet like MetaMask, you add a custom network with the RPC URL, chain ID, and symbol. For programmatic access, you can use libraries like ethers.js or web3.js.

Example using ethers.js: `const provider = new ethers.providers.JsonRpcProvider('https://moonbeam.api.onfinality.io/public');`

For WebSocket connections: `const provider = new ethers.providers.WebSocketProvider('wss://moonbeam.api.onfinality.io/public-ws');`

  • MetaMask: Settings > Networks > Add Network > Enter details.
  • ethers.js: Use JsonRpcProvider or WebSocketProvider.
  • web3.js: Use new Web3('https://...').

Common Moonbeam RPC methods

Moonbeam supports all standard Ethereum JSON-RPC methods. Here are some commonly used ones:

`eth_blockNumber` - Get the latest block number. `eth_getBalance` - Get GLMR balance of an address. `eth_call` - Execute a contract call without creating a transaction. `eth_sendRawTransaction` - Send a signed transaction. `eth_getLogs` - Retrieve event logs.

  • Standard methods: eth_blockNumber, eth_getBalance, eth_call, eth_sendRawTransaction, eth_getLogs.
  • Custom Moonbeam methods: moonbeam_getBlockByNumber, etc.
  • Trace methods: debug_traceTransaction, trace_block.

Troubleshooting Moonbeam RPC issues

Common issues include rate limiting, connection timeouts, and incorrect chain ID. If you encounter errors, first verify your RPC URL and chain ID. For rate limiting, consider upgrading to a higher-tier plan or using a dedicated node.

If you need help, check the Moonbeam documentation or contact your RPC provider's support.

  • Check network configuration: chain ID 1284, symbol GLMR.
  • Monitor rate limits and upgrade if needed.
  • Use WebSocket for real-time data to avoid polling.
  • Ensure your provider supports the methods you need.

Frequently Asked Questions

What is the Moonbeam RPC URL?

A public Moonbeam RPC URL is https://moonbeam.api.onfinality.io/public. For private endpoints, sign up with an RPC provider.

What is the Moonbeam chain ID?

Moonbeam Mainnet chain ID is 1284 (0x504). Moonbase Alpha TestNet chain ID is 1287.

Does Moonbeam support WebSocket?

Yes, Moonbeam supports WebSocket endpoints for real-time event subscriptions. Example: wss://moonbeam.api.onfinality.io/public-ws.

Can I use Ethereum tools with Moonbeam?

Yes, Moonbeam is fully Ethereum-compatible, so tools like MetaMask, Hardhat, and ethers.js work without modification.

How do I get a dedicated Moonbeam RPC endpoint?

Contact an RPC provider like OnFinality to set up a dedicated node for guaranteed performance and custom configuration.

moonbeam rpc
RPC Knowledge Base

Related RPC details

Background

Nunca te preocupes por la infraestructura nuevamente

OnFinality elimina la carga pesada de DevOps para que puedas construir de forma más inteligente y rápida.

Comenzar