Summary
This page lists public Optimism RPC endpoints, chain settings for OP Mainnet and Optimism Sepolia, and guidance on choosing a production-grade RPC provider. Public endpoints are rate-limited and suitable for development, while production apps typically need a managed provider like OnFinality for reliability and scalability.
Quick decision guide: which Optimism RPC should you use?
If you are prototyping, testing, or building a proof-of-concept, a public RPC endpoint is enough. Public endpoints are rate-limited and not designed for production traffic, but they work well for development and light usage.
For production applications, you need a managed RPC provider that offers higher throughput, reliability, and support. OnFinality provides public and dedicated Optimism RPC endpoints with HTTP and WebSocket support. You can start with the public endpoint and upgrade to a dedicated node when your traffic grows. Check RPC pricing and supported networks for details.
Optimism RPC endpoints at a glance
Here are the public RPC endpoints for Optimism networks. These are rate-limited and not suitable for production use.
| Network | Chain ID | Public RPC URL | Explorer |
|---|---|---|---|
| OP Mainnet | 10 | https://optimism.api.onfinality.io/public | optimistic.etherscan.io |
| Optimism Sepolia | 11155420 | https://optimism-sepolia.api.onfinality.io/public | sepolia-optimism.etherscan.io |
These endpoints are provided by OnFinality and are suitable for development and testing. For production, consider a dedicated node or a higher-tier plan.
Chain settings for OP Mainnet and Optimism Sepolia
When connecting a wallet or configuring a dApp, you need the correct chain settings. Below are the details for both networks.
OP Mainnet
- Chain ID: 10
- Currency: ETH (18 decimals)
- RPC URL:
https://optimism.api.onfinality.io/public - Explorer: https://optimistic.etherscan.io
Optimism Sepolia
- Chain ID: 11155420
- Currency: Sepolia ETH (18 decimals)
- RPC URL:
https://optimism-sepolia.api.onfinality.io/public - Explorer: https://sepolia-optimism.etherscan.io
How to add Optimism to MetaMask or other wallets
Most wallets allow you to add a custom network. Use the chain settings above. Here is an example for MetaMask:
{
"chainId": "0xa",
"chainName": "OP Mainnet",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"rpcUrls": ["https://optimism.api.onfinality.io/public"],
"blockExplorerUrls": ["https://optimistic.etherscan.io"]
}
For Optimism Sepolia, use chain ID 0xaa37dc (11155420) and the Sepolia RPC URL.
Connecting to Optimism with ethers.js and viem
Here are code examples for connecting to Optimism using popular libraries.
ethers.js
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("https://optimism.api.onfinality.io/public");
const network = await provider.getNetwork();
console.log(network.chainId); // 10n
viem
import { createPublicClient, http } from 'viem';
import { optimism } from 'viem/chains';
const client = createPublicClient({
chain: optimism,
transport: http("https://optimism.api.onfinality.io/public")
});
const blockNumber = await client.getBlockNumber();
console.log(blockNumber);
Public vs. production RPC: what to consider
Public RPC endpoints are free and easy to use, but they come with limitations:
- Rate limits: Public endpoints are shared and rate-limited. High traffic can cause throttling or errors.
- Reliability: Public endpoints may go down or become slow during peak usage.
- No SLA: There is no guarantee of uptime or performance.
For production applications, you need a provider that offers:
- Higher throughput: More requests per second to handle your user base.
- Dedicated resources: A dedicated node gives you isolated performance.
- WebSocket support: For real-time updates and subscriptions.
- Archive data: If you need historical state or trace data.
- Support: Access to technical support when issues arise.
OnFinality offers both public and dedicated Optimism RPC endpoints. You can start with the public endpoint and upgrade as your needs grow. See RPC pricing for plans and supported networks for the full list.
Evaluating Optimism RPC providers
When comparing providers, consider the following criteria:
| Criterion | What to check | Why it matters |
|---|---|---|
| Throughput | Requests per second (RPS) limits | Determines if the provider can handle your traffic |
| WebSocket support | Does the provider offer WSS? | Needed for real-time dApps |
| Archive data | Does the provider offer archive nodes? | Required for historical queries and some analytics |
| Trace support | Does the provider support debug_traceTransaction? | Useful for debugging and indexing |
| Global presence | Are there multiple regions? | Reduces latency and improves reliability |
| Pricing model | Pay-as-you-go vs. subscription | Affects cost predictability |
| Support | Is there 24/7 support? | Critical for production incidents |
OnFinality is a strong option for Optimism RPC, offering public and dedicated endpoints with HTTP and WebSocket support. You can find more details on the Optimism network page.
Common pitfalls and troubleshooting
Here are common issues developers face when using Optimism RPC and how to resolve them.
Rate limiting
If you see errors like 429 Too Many Requests, you are hitting rate limits. Solutions:
- Use a dedicated node or higher-tier plan.
- Implement caching on your side.
- Use WebSocket for real-time data instead of polling.
Connection timeouts
If your requests time out, check:
- Your network connection.
- The RPC endpoint status.
- If you are using a public endpoint, consider switching to a dedicated node.
Wrong chain ID
Ensure your wallet or dApp is configured with the correct chain ID (10 for mainnet, 11155420 for Sepolia).
WebSocket disconnections
WebSocket connections can drop. Implement reconnection logic in your client.
Key Takeaways
- Public Optimism RPC endpoints are available for development and testing, but are rate-limited.
- For production, use a managed RPC provider like OnFinality for reliability and scalability.
- Chain settings are straightforward: chain ID 10 for mainnet, 11155420 for Sepolia.
- Evaluate providers based on throughput, WebSocket support, archive data, and support.
- Start with a public endpoint and upgrade to a dedicated node as your traffic grows.
Frequently Asked Questions
What is the official Optimism RPC URL?
The official public RPC URL for OP Mainnet is https://mainnet.optimism.io. However, it is rate-limited and not recommended for production. OnFinality provides a public endpoint at https://optimism.api.onfinality.io/public.
What is the Optimism chain ID?
OP Mainnet uses chain ID 10. Optimism Sepolia uses chain ID 11155420.
How do I get a production Optimism RPC endpoint?
You can sign up for a managed RPC provider like OnFinality. Visit RPC pricing to see plans and get an API key.
Does OnFinality support WebSocket for Optimism?
Yes, OnFinality supports both HTTP and WebSocket for Optimism networks. See the network page for details.
Can I use the public endpoint for production?
Public endpoints are rate-limited and not suitable for production. Use a dedicated node or a higher-tier plan for production workloads.
What is the difference between OP Mainnet and Optimism Sepolia?
OP Mainnet is the production network with real ETH. Optimism Sepolia is a testnet with Sepolia ETH, used for testing and development.
How do I add Optimism to MetaMask?
Use the chain settings provided above. You can also use ChainList to add the network automatically.
What are the best Optimism RPC providers?
Several providers offer Optimism RPC, including OnFinality, Alchemy, Infura, and QuickNode. Compare them based on your specific needs, such as throughput, archive data, and pricing. OnFinality is a good option to consider, with public and dedicated endpoints available.
Does OnFinality offer archive nodes for Optimism?
OnFinality provides archive node support for many networks. Check the Optimism network page or contact support for specific archive availability.
How do I troubleshoot RPC errors on Optimism?
Common issues include rate limiting, timeouts, and wrong chain ID. Refer to the troubleshooting section above for solutions. If problems persist, contact your RPC provider's support.