Docs

Optimism RPC - Fast & Reliable Optimism Node API

Access Optimism's Layer 2 network through Dwellir's high-performance RPC endpoints. Fast, reliable, and developer-friendly Optimism node infrastructure.

Optimism RPC

With Dwellir, you get access to our global Optimism network which always routes your API requests to the nearest available location, ensuring low latency and the fastest speeds.

Get your API key

Network Overview

Optimism is a Layer 2 scaling solution for Ethereum that uses optimistic rollups to achieve faster transactions and lower fees while maintaining Ethereum's security. As one of the leading L2 solutions, Optimism provides an EVM-equivalent environment that makes it easy for developers to deploy existing Ethereum applications.

Key Features

High Performance

  • Fast Transactions: Sub-second block times with instant transaction confirmation
  • Low Costs: Up to 100x lower gas fees compared to Ethereum mainnet
  • High Throughput: Process thousands of transactions per second

Security & Reliability

  • Ethereum Security: Inherits security from Ethereum mainnet
  • Fraud Proofs: Optimistic rollup design with challenge period for security
  • 99.99% Uptime: Enterprise-grade infrastructure with global redundancy

Developer Experience

  • EVM Equivalence: Deploy existing Solidity contracts without modification
  • Full JSON-RPC: Complete Ethereum JSON-RPC API compatibility
  • Archive Data: Access to full historical blockchain data
  • Debug & Trace APIs: Advanced debugging capabilities for developers

Optimism-specific helpers such as rollup_getInfo, rollup_gasPrices, and eth_estimateL1Fee are not exposed on Dwellir's public Optimism endpoints. Use standard Ethereum JSON-RPC methods for fee estimation and consult Optimism's own docs for rollup metadata.

Quick Start

Optimism RPC Endpoints
HTTPS
curl -sS -X POST https://api-optimism-mainnet-archive.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots> \  -H 'Content-Type: application/json' \  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
import { JsonRpcProvider } from 'ethers';const provider = new JsonRpcProvider(  'https://api-optimism-mainnet-archive.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots>');const latest = await provider.getBlockNumber();console.log('block', latest);
import requestsurl = 'https://api-optimism-mainnet-archive.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots>'payload = {  'jsonrpc': '2.0', 'id': 1,  'method': 'eth_blockNumber', 'params': []}resp = requests.post(url, json=payload)print(resp.json())
package mainimport (  "bytes"  "fmt"  "io"  "net/http")func main() {  url := "https://api-optimism-mainnet-archive.n.dwellir.com/<API_Keys_Are_Not_Made_for_Bots>"  payload := []byte(`{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}`)  resp, err := http.Post(url, "application/json",    bytes.NewBuffer(payload))  if err != nil { panic(err) }  defer resp.Body.Close()  body, _ := io.ReadAll(resp.Body)  fmt.Println(string(body))}

Network Information

Mainnet Configuration

ParameterValueDetails
Network NameOptimism Mainnet
Chain ID10 (0xa)
Currency SymbolETH
Block ExplorerOptimism Explorer

Testnet Configuration

ParameterValueDetails
Network NameOptimism Sepolia
Chain ID11155420 (0xaa37dc)
Currency SymbolETH
Block ExplorerOptimism Sepolia Explorer

Supported APIs

Our Optimism endpoints support the complete Ethereum JSON-RPC specification plus Optimism-specific methods:

Core APIs

  • Standard Ethereum JSON-RPC: All eth_* methods
  • Web3 Methods: web3_clientVersion, web3_sha3
  • Net Methods: net_version, net_listening, net_peerCount
  • Debug API: Transaction and block tracing
  • Filter API: Event and log filtering
  • Subscription API: Real-time updates via WebSocket

Optimism Compatibility

  • Gas Estimation: Use eth_estimateGas and eth_gasPrice for standard fee checks
  • Rollup Helpers: rollup_getInfo, rollup_gasPrices, and eth_estimateL1Fee return Method not found on the public archive endpoints
  • Sequencer Status: Check Optimism's own status and documentation for rollup-level health details

Use Cases

DeFi Applications

Build decentralized exchanges, lending protocols, and yield optimizers with low transaction costs and fast confirmation times.

NFT Marketplaces

Deploy NFT collections and marketplaces with affordable minting and trading, perfect for high-volume applications.

Gaming & Metaverse

Create blockchain games and virtual worlds where users can perform frequent transactions without high gas costs.

DAO Infrastructure

Implement governance systems with affordable voting and proposal execution, enabling more democratic participation.

Integration Examples

Web3.js

JavaScript
const Web3 = require('web3');
const web3 = new Web3('https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY');

// Get latest block
const block = await web3.eth.getBlock('latest');
console.log('Latest block:', block.number);

// Check balance
const balance = await web3.eth.getBalance('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0');
console.log('Balance:', web3.utils.fromWei(balance, 'ether'), 'ETH');

Ethers.js

JavaScript
const { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider('https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY');

// Get network info
const network = await provider.getNetwork();
console.log('Connected to:', network.name, 'Chain ID:', network.chainId);

// Estimate L2 gas
const gasPrice = await provider.getFeeData();
console.log('Gas price:', ethers.formatUnits(gasPrice.gasPrice, 'gwei'), 'gwei');

viem

TypeScript
import { createPublicClient, http } from 'viem';
import { optimism } from 'viem/chains';

const client = createPublicClient({
  chain: optimism,
  transport: http('https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY'),
});

// Get chain ID
const chainId = await client.getChainId();
console.log('Chain ID:', chainId);

// Read contract
const balance = await client.getBalance({
  address: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0',
});
console.log('Balance:', balance);

Migration Guide

From Other Providers

Migrating to Dwellir is simple:

  1. Sign up for an API key at dashboard.dwellir.com
  2. Replace your current RPC URL with Dwellir's Optimism endpoint
  3. No code changes required - we support the full Ethereum JSON-RPC spec

From Ethereum Mainnet

Deploying from Ethereum to Optimism:

  1. Your Solidity contracts work without modification
  2. Use the same deployment tools (Hardhat, Truffle, Foundry)
  3. Update your provider URL to our Optimism endpoint
  4. Benefit from 100x lower gas costs

Best Practices

Optimize for L2

  • Batch Operations: Group multiple operations to save on L1 data costs
  • Event Monitoring: Use filters and subscriptions for efficient event tracking
  • Gas Estimation: Always estimate both L1 and L2 costs before transactions

Error Handling

JavaScript
try {
  const result = await provider.send('eth_call', [tx, 'latest']);
  return result;
} catch (error) {
  if (error.code === -32603) {
    // Internal error, retry with exponential backoff
    await delay(1000);
    return retry();
  }
  throw error;
}

Troubleshooting

Common Issues

Connection Timeouts

  • Check your API key is valid
  • Ensure you're using the correct network endpoint
  • Verify your firewall allows HTTPS connections

Nonce Too Low

  • Optimism processes transactions quickly
  • Always fetch the latest nonce before sending transactions
  • Consider using pending nonce for successive transactions

L1 Data Fee Estimation

  • Use eth_estimateGas for L2 execution cost
  • Calculate L1 data fee separately using rollup gas oracle
  • Total cost = L2 execution cost + L1 data cost

Additional Resources

Support

Need help with your Optimism integration?


Start building on Optimism with Dwellir's reliable RPC infrastructure. Get your API key and join thousands of developers scaling Ethereum applications.