DEV Community

Zhuoxin Sun
Zhuoxin Sun

Posted on • Originally published at onfinality.io

Optimism RPC Endpoints: Chain Settings, Methods, and Provider Selection

Optimism RPC decision checklist

Before integrating an Optimism RPC endpoint into your wallet, dApp, or backend, evaluate the following:

  • Network match – Are you connecting to OP Mainnet (chain ID 10) or OP Sepolia testnet (chain ID 11155420)? Mixing up chain IDs can lead to lost transactions.
  • Endpoint type – Public endpoints are rate-limited and may lack WebSocket support. For production use, consider a managed RPC provider that offers higher rate limits and archive data.
  • Data requirements – Do you need full transaction history? Archive nodes store historical state. Do you need event logs or trace calls? Not all endpoints expose the debug_ or trace_ methods.
  • Latency and reliability – If your app is latency-sensitive (e.g., trading or gaming), check the provider’s historical response times and uptime. A dedicated node may offer better consistency.
  • WebSocket vs HTTP – For real‑time subscriptions (e.g., pending transactions or log events), ensure the endpoint supports wss://. Many free RPCs omit WebSocket.
  • Budget – Free public RPCs work for development but become unreliable under load. Compare pricing tiers for shared and dedicated nodes.

Optimism network overview

Optimism is an Ethereum Layer 2 scaling solution using Optimistic Rollups. It processes transactions off-chain and posts compressed data to Ethereum, inheriting Ethereum’s security. OP Mainnet is the production network; OP Sepolia is the testnet for development.

Chain settings

Parameter OP Mainnet OP Sepolia
Network Name OP Mainnet OP Sepolia
Chain ID 10 (0x0a) 11155420 (0xaa37dc)
Native Currency ETH ETH
Block Explorer (official) https://explorer.optimism.io https://testnet-explorer.optimism.io
Public RPC URL https://mainnet.optimism.io https://sepolia.optimism.io
Sequencer URL (write only) https://mainnet-sequencer.optimism.io https://sepolia-sequencer.optimism.io
Flashblocks WebSocket wss://op-mainnet-fb-ws-pub.optimism.io/ws wss://op-sepolia-fb-ws.optimism.io/ws

⚠️ The official public RPC URLs are rate‑limited and do not support WebSocket connections. For reliable access, use a third‑party RPC provider.


How to connect to Optimism RPC

Connecting via cURL

Test your Optimism RPC endpoint with a simple eth_blockNumber call:

curl -X POST https://mainnet.optimism.io \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
Enter fullscreen mode Exit fullscreen mode

Expected response (hex block number):

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x936adc3"
}
Enter fullscreen mode Exit fullscreen mode

Connecting via JavaScript (ethers.js)

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("https://mainnet.optimism.io");
provider.getBlockNumber().then(console.log);
Enter fullscreen mode Exit fullscreen mode

Adding to a wallet (MetaMask)

  1. Open MetaMask → Network dropdown → Add NetworkAdd a network manually.
  2. Fill in:
    • Network Name: OP Mainnet
    • RPC URL: https://mainnet.optimism.io or a provider URL
    • Chain ID: 10
    • Symbol: ETH
    • Block Explorer: https://explorer.optimism.io
  3. Click Save.

Providers like OnFinality offer dedicated Optimism RPC endpoints with higher rate limits and optional WebSocket support. See supported RPC networks for available endpoints.


Common JSON‑RPC methods on Optimism

Optimism is EVM‑compatible, so standard Ethereum methods work. Here are some frequently used ones:

Method Purpose
eth_blockNumber Get the latest block number
eth_getBalance Get ETH balance of an address
eth_call Execute a read‑only contract call
eth_sendRawTransaction Broadcast a signed transaction
eth_getTransactionReceipt Get transaction receipt by hash
eth_getLogs Retrieve event logs matching filter
eth_estimateGas Estimate gas for a transaction
net_version Return the network ID (10)
web3_clientVersion Return the client version

For archive and debug methods (e.g., eth_getProof, debug_traceTransaction), you need an archive node provider.


Choosing an Optimism RPC provider

When selecting a provider for production, consider these criteria:

Criterion What to check Why it matters
Rate limits Requests per second (RPS) and daily cap Free public RPCs often throttle at <10 RPS; higher limits are needed for live dapps
WebSocket support Whether wss:// endpoint is available Real‑time features like eth_subscribe require WebSocket
Archive data Support for historical state and debug methods Necessary for indexers, explorers, and analytic tools
Uptime SLA Published uptime commitment or historical track record Downtime can break your application and cause user frustration
Latency Average response time and geographic distribution Lower latency improves user experience, especially for interactive dapps
Pricing model Pay‑per‑request, monthly plan, or dedicated node Choose a model that fits your budget and growth projections
Security & privacy TLS encryption, IP masking, and no logging policies Protects your users’ data and prevents request interception
Multi‑chain support Whether the provider also covers other networks you need Simplifies integration if you work with multiple chains

OnFinality provides Optimism RPC endpoints with flexible plans, including dedicated nodes for high‑throughput projects. Check RPC pricing for details.


Optimism RPC vs running your own node

Running a full Optimism node requires: an Ethereum L1 endpoint (for data availability), significant storage (~2 TB for archive), and maintenance overhead. A managed RPC provider abstracts this complexity.

Aspect Managed RPC Self‑hosted node
Setup time Minutes Hours to days
Maintenance Provider handles upgrades You manage snapshots, updates, and monitoring
Scalability Built‑in load balancing Requires additional infrastructure
Cost Pay‑as‑you‑go or fixed plans Hardware, bandwidth, and engineering time

For most development and production use cases, a managed Optimism RPC provider is the practical choice.


Troubleshooting common Optimism RPC issues

  1. Chain ID mismatch – Ensure you are using chain ID 10 for mainnet and 11155420 for Sepolia. A wrong chain ID causes transactions to fail with invalid sender.
  2. Rate limit exceeded – Public endpoints return 429 Too Many Requests. Move to a provider with higher limits or upgrade to a dedicated node.
  3. Missing WebSocket – If you need real‑time subscriptions, verify the endpoint URL starts with wss://. Many free RPCs do not offer WebSocket.
  4. Block number not found – Some endpoints only serve recent blocks. Use an archive provider if historical data is required.
  5. eth_getLogs timeout – Filter ranges that are too wide can time out. Narrow your block range or use a provider that supports large queries.

Key Takeaways

  • Optimism provides public RPC endpoints for OP Mainnet and OP Sepolia, but they are rate‑limited and lack WebSocket support.
  • For production, evaluate providers on rate limits, WebSocket, archive data, latency, and pricing.
  • Managed RPC services like OnFinality simplify infrastructure by handling node operation, scaling, and failover.
  • Standard Ethereum JSON‑RPC methods work on Optimism; additional methods like eth_getProof require an archive node.
  • Always test your endpoint with a simple eth_blockNumber call before building your integration.

Frequently Asked Questions

What is the official Optimism RPC URL?

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

Can I use Ethereum RPC providers for Optimism?

Yes, many providers offer Optimism endpoints. OnFinality supports Optimism as part of its network list.

Does Optimism support WebSocket?

Yes, Optimism provides a Flashblocks WebSocket at wss://op-mainnet-fb-ws-pub.optimism.io/ws, but it is intended for specific low‑latency use cases. For standard WebSocket RPC, use a third‑party provider.

What is the Optimism chain ID?

OP Mainnet: 10 (0x0a). OP Sepolia: 11155420 (0xaa37dc).

How do I get an Optimism archive RPC endpoint?

Archive endpoints are available from providers like OnFinality. Check the pricing page for archive node options.

Why am I getting "429 Too Many Requests"?

The official public endpoint has strict rate limits. Switch to a managed provider with higher limits or a dedicated node.

Related resources

Originally published at OnFinality.

Top comments (0)