Logo

Optimism RPC: How to Connect to OP Mainnet and Choose the Best Endpoint

Key Takeaways

  • Optimism RPC endpoints allow you to interact with OP Mainnet, a Layer 2 Ethereum scaling solution.
  • The official public RPC URL (https://mainnet.optimism.io) is rate-limited and does not support WebSocket connections.
  • Third-party providers offer private, dedicated, and WebSocket-enabled Optimism RPC endpoints for production use.
  • Chain ID for OP Mainnet is 10, and the native currency is ETH.
  • Adding Optimism to MetaMask requires the RPC URL, Chain ID, and currency symbol.
  • For high-traffic dApps, a dedicated Optimism node provides guaranteed performance and reliability.
  • OnFinality provides Optimism RPC endpoints with scalable infrastructure for developers and enterprises.

What is Optimism RPC?

Optimism RPC (Remote Procedure Call) is the protocol that enables wallets, dApps, and other Web3 applications to communicate with the Optimism blockchain. By sending JSON-RPC requests to an Optimism RPC endpoint, you can read blockchain data, submit transactions, and interact with smart contracts on OP Mainnet.

Optimism is an Ethereum Layer 2 scaling solution that uses Optimistic Rollups to bundle transactions off-chain and submit them to Ethereum, significantly reducing gas costs and increasing throughput. The RPC interface is fully EVM-compatible, meaning you can use the same Ethereum JSON-RPC methods and tools like Web3.js, ethers.js, and viem.

  • EVM-compatible: Use standard Ethereum RPC methods (eth_call, eth_sendTransaction, etc.)
  • Chain ID: 10 (0xa) for OP Mainnet, 11155420 for OP Sepolia testnet
  • Native currency: ETH (same as Ethereum)
  • Supports both HTTP and WebSocket transports (depending on provider)

Official Optimism RPC Endpoints

The Optimism Foundation provides public RPC endpoints for OP Mainnet and OP Sepolia. These are free to use but come with rate limits and do not support WebSocket connections. For production applications or WebSocket needs, you should use a third-party RPC provider or run your own node.

Below are the official public endpoints:

CriterionWhat to checkWhy it matters
NetworkOP MainnetProduction Layer 2 network
Public RPC URLhttps://mainnet.optimism.ioRate-limited, no WebSocket
Chain ID10 (0xa)Required for wallet configuration
Currency SymbolETHUsed for gas fees
Block Explorerhttps://explorer.optimism.ioView transactions and contracts
WebSocketNot supported on public endpointUse third-party provider for real-time data

How to Add Optimism to MetaMask

Adding Optimism to MetaMask requires configuring a custom network with the correct RPC URL, Chain ID, and currency symbol. You can do this manually or use one-click tools like ChainList.

  • Open MetaMask and click the network dropdown at the top.
  • Select 'Add Network' and then 'Add a network manually'.
  • Enter the following details:
  • - Network Name: OP Mainnet
  • - RPC URL: https://mainnet.optimism.io (or a third-party provider URL)
  • - Chain ID: 10
  • - Currency Symbol: ETH
  • - Block Explorer URL: https://explorer.optimism.io
  • Click 'Save' to add the network.

Choosing the Best Optimism RPC Provider

While the official public endpoint is fine for testing, production dApps require reliable, high-performance RPC access. Factors to consider when choosing an Optimism RPC provider include uptime, latency, rate limits, WebSocket support, and pricing.

Third-party providers offer various tiers: free public endpoints with rate limits, premium shared endpoints with higher throughput, and dedicated nodes for maximum performance. Some providers also offer archive data and trace API support.

  • Uptime and reliability: Look for providers with SLAs and redundant infrastructure.
  • Latency: Low-latency endpoints are critical for time-sensitive applications like trading.
  • Rate limits: Free tiers often cap requests per second; paid plans offer higher limits.
  • WebSocket support: Required for real-time updates (e.g., pending transactions, event logs).
  • Archive data: Needed for historical state queries beyond the default 128 blocks.
  • Geographic distribution: Global nodes reduce latency for users worldwide.

Optimism RPC with OnFinality

OnFinality offers Optimism RPC endpoints as part of its managed blockchain infrastructure service. Developers can access scalable, reliable RPC APIs for OP Mainnet without managing their own nodes. OnFinality supports both HTTP and WebSocket connections, with options for dedicated nodes for high-traffic applications.

By using OnFinality, you benefit from global node distribution, automatic failover, and flexible pricing. Whether you're building a DeFi protocol, NFT marketplace, or gaming dApp, OnFinality's Optimism RPC endpoints provide the performance and reliability needed for production.

  • HTTP and WebSocket endpoints available
  • Scalable infrastructure with load balancing
  • Dedicated node options for guaranteed performance
  • Easy integration with existing Ethereum tooling

Optimism RPC Troubleshooting Tips

When working with Optimism RPC, you may encounter common issues like rate limiting, connection errors, or incorrect chain configuration. Here are some tips to resolve them.

  • Rate limiting: Switch to a provider with higher rate limits or use a dedicated node.
  • Connection errors: Verify the RPC URL is correct and the network is reachable.
  • WebSocket not connecting: Ensure your provider supports WebSocket and you're using the correct URL.
  • Incorrect Chain ID: Double-check that your wallet or dApp is configured with Chain ID 10 for OP Mainnet.
  • Transaction failures: Check gas limits and ensure you have sufficient ETH for fees.

Frequently Asked Questions

Frequently Asked Questions

What is the official Optimism RPC URL?

The official public RPC URL for OP Mainnet is https://mainnet.optimism.io. It is rate-limited and does not support WebSocket connections.

Does Optimism RPC support WebSocket?

The official public endpoint does not support WebSocket. For real-time data, use a third-party provider that offers WebSocket endpoints.

What Chain ID does Optimism use?

OP Mainnet uses Chain ID 10 (0xa). The testnet OP Sepolia uses Chain ID 11155420.

Can I use Optimism RPC for free?

Yes, the official public endpoint is free but rate-limited. Many third-party providers also offer free tiers with limited requests per day.

How do I get a dedicated Optimism RPC endpoint?

Providers like OnFinality offer dedicated Optimism nodes for production use. Contact the provider for pricing and setup.

optimism rpc
RPC Knowledge Base

Related RPC details

Background

Never Worry about Infrastructure Again

OnFinality takes away the heavy lifting of DevOps so you can build smarter and faster.

Get Started