# Optimism RPC - Fast & Reliable Optimism Node API

## Optimism RPC plans and rate limits

- **Free plan:** 20 responses per second, up to 100,000 responses a day.
- **Plans:** $49/mo, $299/mo, $999/mo with 25M, 150M, and 500M included responses. Overages billed at $5/$3/$2 per million responses respectively.
- **Paid rate limits:** 100 to 5,000 responses per second (bursts from 500 to 10,000), no daily limit.
- **Billing:** 1 response = 1 API credit on every shared plan, over HTTPS or WebSocket (WSS) where Optimism supports it.

Details: [Pricing](https://www.dwellir.com/docs/getting-started/pricing) · [Rate limits](https://www.dwellir.com/docs/getting-started/rate-limits) · [Authentication](https://www.dwellir.com/docs/getting-started/authentication) · [Archive nodes](https://www.dwellir.com/docs/getting-started/archive-nodes)

## 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](https://ethereum.org/developers/docs/apis/json-rpc/) 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

## Network Information

### Mainnet Configuration

| Parameter       | Value                                                | Details |
| --------------- | ---------------------------------------------------- | ------- |
| Network Name    | Optimism Mainnet                                     |         |
| Chain ID        | 10 (0xa)                                             |         |
| Currency Symbol | ETH                                                  |         |
| Block Explorer  | [Optimism Explorer](https://optimistic.etherscan.io) |         |

### Testnet Configuration

| Parameter       | Value                                                              | Details |
| --------------- | ------------------------------------------------------------------ | ------- |
| Network Name    | Optimism Sepolia                                                   |         |
| Chain ID        | 11155420 (0xaa37dc)                                                |         |
| Currency Symbol | ETH                                                                |         |
| Block Explorer  | [Optimism Sepolia Explorer](https://sepolia-optimism.etherscan.io) |         |

## 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](https://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

- [Optimism Official Documentation](https://docs.optimism.io)
- [Optimism GitHub](https://github.com/ethereum-optimism)
- [Block Explorer](https://optimistic.etherscan.io)
- [Network Status](https://status.optimism.io)
- [Bridge Interface](https://app.optimism.io/bridge)

## Support

Need help with your Optimism integration?

- Email: <support@dwellir.com>
- Documentation: [Full API Reference](https://www.dwellir.com/docs/optimism)
- Dashboard: [dashboard.dwellir.com](https://dashboard.dwellir.com)

***

Start building on Optimism with Dwellir's reliable RPC infrastructure. [Get your API key](https://dashboard.dwellir.com/register) and join thousands of developers scaling Ethereum applications.
