# Base - Ethereum L2 Documentation

## Base 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 Base 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)

## Why Build on Base?

Base is Coinbase's Ethereum Layer 2 solution, designed to bring the next billion users onchain. Built on Optimism's OP Stack, Base offers:

### **Lightning Fast Performance**

- **200ms blocks** - A complete canonical block every 200ms since the Denim upgrade
- **10-100x lower costs** than Ethereum mainnet
- **EIP-4844 enabled** - Leveraging blob data for even lower fees

### **Enterprise Security**

- **Backed by Coinbase** - Institutional-grade infrastructure
- **Ethereum security** - Inherits L1 security guarantees
- **Battle-tested** - Built on proven Optimism technology

### **Massive Ecosystem**

- **1M+ weekly active users** - Rapidly growing user base
- **$2B+ TVL** - Strong DeFi ecosystem
- **Major integrations** - Circle USDC, Chainlink, The Graph

## Quick Start with Base

Connect to Base in seconds with Dwellir's optimized endpoints:

### Installation & Setup

Ethers.js v6
Web3.js
Viem

```javascript
import { JsonRpcProvider } from 'ethers';

// Connect to Base mainnet
const provider = new JsonRpcProvider(
  'https://api-base-mainnet-archive.n.dwellir.com/YOUR_API_KEY'
);

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

// Query account balance
const balance = await provider.getBalance('0x...');
console.log('Balance:', balance.toString());
```

```javascript
const Web3 = require('web3');

// Connect to Base mainnet
const web3 = new Web3(
  'https://api-base-mainnet-archive.n.dwellir.com/YOUR_API_KEY'
);

// Get chain ID to verify connection
const chainId = await web3.eth.getChainId();
console.log('Connected to Base:', chainId === 8453);

// Get gas price for optimal transaction pricing
const gasPrice = await web3.eth.getGasPrice();
console.log('Current gas price:', gasPrice);
```

```typescript
import { createPublicClient, http } from 'viem';
import { base } from 'viem/chains';

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

// Read contract data
const data = await client.readContract({
  address: '0x...',
  abi: contractAbi,
  functionName: 'balanceOf',
  args: ['0x...'],
});
```

## Network Information

| Parameter    | Value    | Details                      |
| ------------ | -------- | ---------------------------- |
| Chain ID     | 8453     | Mainnet                      |
| Block Time   | 200ms    | Canonical blocks since Denim |
| Gas Token    | ETH      | Native token                 |
| RPC Standard | Ethereum | JSON-RPC 2.0                 |

## API Reference

Base supports the full [Ethereum JSON-RPC API specification](https://ethereum.org/developers/docs/apis/json-rpc/) plus Base-specific methods.

## Denim and 200ms blocks

Base activated the [Denim upgrade](https://docs.base.org/upgrades/denim/200ms-blocks) on Base Sepolia on October 21, 2026, and on Base Mainnet on November 5, 2026. Base now produces one complete canonical block every 200ms. Each block has its own number, hash, state root, and receipts.

A 200ms block is not finality. Every block still moves through the unsafe, safe, and finalized states, so keep your confirmation policy and reorg handling.

Check two assumptions in existing code:

- **Block counts:** `block.number` advances 10 times faster than before Denim. Audit deadlines and cooldowns that count blocks.
- **Timestamps:** `timestamp` stays in whole seconds. Block and header responses add an optional `timestampMs` field. Mined transactions and logs add an optional `blockTimestampMs` field. Handle both when absent.

### Flashblocks history

From July 2025 until Denim, Flashblocks streamed 200ms preconfirmations inside 2-second canonical blocks. Denim retired them. Flashblocks subscriptions no longer deliver notifications, and preconfirmed state has no direct replacement.

If your code still uses a Flashblocks interface, replace it:

| Flashblocks interface       | Use now                                                                                    |
| --------------------------- | ------------------------------------------------------------------------------------------ |
| `newFlashblocks`            | `newHeads`                                                                                 |
| `pendingLogs`               | `logs`                                                                                     |
| `newFlashblockTransactions` | `newHeads`, then fetch each canonical block                                                |
| `"pending"` reads           | `"latest"`. Base still accepts `"pending"`, but it resolves to the latest canonical block. |
| Preconfirmed receipts       | `eth_getTransactionReceipt` once the transaction is in a canonical block                   |

The [Base Denim migration guide](https://www.dwellir.com/blog/base-denim-migration-guide) explains each change. Base publishes the [full migration table](https://docs.base.org/upgrades/denim/migrate-from-flashblocks).

## Common Integration Patterns

### Transaction Monitoring

Monitor pending and confirmed transactions efficiently:

```javascript
// Watch for transaction confirmation
async function waitForTransaction(txHash) {
  const receipt = await provider.waitForTransaction(txHash, 1);

  // L2 specific: Check L1 data availability
  if (receipt.l1Fee) {
    console.log('L1 data cost:', receipt.l1Fee);
  }

  return receipt;
}
```

### Gas Optimization

Optimize gas costs on Base L2:

```javascript
// Estimate L2 execution gas
const l2Gas = await provider.estimateGas(tx);

// Get current L1 data fee (Base specific)
const l1DataFee = await provider.send('eth_estimateL1Fee', [tx]);

// Total cost = L2 execution + L1 data posting
const totalCost = l2Gas + BigInt(l1DataFee);
```

### Event Filtering

Efficiently query contract events:

```javascript
// Query events with automatic retry and pagination
async function getEvents(contract, eventName, fromBlock = 0) {
  const filter = contract.filters[eventName]();
  const events = [];
  const batchSize = 2000; // Base recommended batch size

  for (let i = fromBlock; i <= currentBlock; i += batchSize) {
    const batch = await contract.queryFilter(
      filter,
      i,
      Math.min(i + batchSize - 1, currentBlock)
    );
    events.push(...batch);
  }

  return events;
}
```
