⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

Berachain - Build on the Proof‑of‑Liquidity EVM Layer 1

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

Get your API key →

Why Build on Berachain?

🚀 High‑Performance EVM

  • Built on a modular EVM (Polaris) for efficient execution and developer‑friendly precompiles
  • Fast finality via CometBFT (BFT consensus), ideal for low‑latency reads and responsive UX
  • EVM compatibility out of the box — keep using Solidity, Hardhat, Foundry, viem, and ethers.js

💧 Proof‑of‑Liquidity Alignment

  • Separation of gas and governance unlocks healthier incentive design
  • Liquidity provision powers governance emissions (BGT) to align validators, protocols, and users
  • Ecosystem‑driven rewards encourage deep liquidity for DeFi building blocks

🔗 Interoperability & Modularity

  • Cosmos SDK foundation with IBC‑friendly architecture for cross‑chain connectivity
  • Polaris EVM’s modular design enables stateful precompiles and chain‑specific extensions without breaking EVM apps
  • Drop‑in migration: reuse your contracts, tooling, and workflows

Quick Start with Berachain

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

🔗 RPC Endpoints

Berachain Mainnet (Chain ID: 80094)Live
https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY
✓ Full Node✓ Debug API✓ WebSocket

Quick Connect:

curl -X POST https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Installation & Setup

# Check latest block
curl -s -X POST https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

# Verify chain id
curl -s -X POST https://api-berachain-bepolia.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'

Network Information

Mainnet Chain ID

80094 (0x138de)

Berachain Mainnet

Testnet Chain ID

80069 (0x138c5)

Bepolia Testnet

RPC Standard

Ethereum JSON-RPC 2.0

EVM-compatible

JSON-RPC API Reference

Berachain supports the full Ethereum JSON-RPC API.

Available JSON-RPC Methods

📊 Reading Blockchain Data

Query blocks, transactions, and account states

+

📤 Sending Transactions

Submit and manage transactions

+

📝 Smart Contract Interaction

Call and interact with smart contracts

+

🔧 Node & Network Info

Query node status and network information

+

Ready to integrate Berachain into your dApp?

Get your API key →

Common Integration Patterns

🔄 Transaction Monitoring

Monitor pending and confirmed transactions efficiently:

async function waitForConfirmations(provider, txHash, confirmations = 1) {
const receipt = await provider.waitForTransaction(txHash, confirmations);
return receipt;
}

💰 Gas Optimization

Use EIP‑1559 dynamic fees and estimate execution gas:

const feeData = await provider.getFeeData();
const tx = {
to: recipient,
value: amount,
maxFeePerGas: feeData.maxFeePerGas,
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
gasLimit: await provider.estimateGas({ to: recipient, value: amount }),
};

🔍 Event Filtering

Query events in bounded ranges to avoid overfetching:

async function getEvents(contract, filter, fromBlock, toBlock, batchSize = 2000) {
const events = [];
for (let i = fromBlock; i <= toBlock; i += batchSize) {
const batch = await contract.queryFilter(filter, i, Math.min(i + batchSize - 1, toBlock));
events.push(...batch);
}
return events;
}

Performance Best Practices

1. Batch Requests

Combine independent calls in a single POST to reduce round‑trips:

const batch = [
{ jsonrpc: '2.0', method: 'eth_blockNumber', params: [], id: 1 },
{ jsonrpc: '2.0', method: 'eth_gasPrice', params: [], id: 2 },
{ jsonrpc: '2.0', method: 'eth_chainId', params: [], id: 3 }
];

const res = await fetch('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(batch)
});
const results = await res.json();

2. Connection Pooling

Reuse provider/clients instead of recreating per call:

import { JsonRpcProvider } from 'ethers';
class BeraProvider {
static instance: JsonRpcProvider | null = null;
static get() {
if (!this.instance) {
this.instance = new JsonRpcProvider('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY');
}
return this.instance;
}
}

3. Smart Caching

Cache immutable data (e.g., past blocks, ABIs) and debounce hot paths:

const cache = new Map<string, unknown>();
async function getBlockCached(n: number) {
const k = `block_${n}`;
if (!cache.has(k)) {
cache.set(k, await BeraProvider.get().getBlock(n));
}
return cache.get(k);
}

Migration Guide

Moving from Ethereum or another EVM chain typically requires:

// Before
const provider = new JsonRpcProvider('https://eth.example');

// After (Berachain mainnet)
const provider = new JsonRpcProvider('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY');

Resources & Tools

Troubleshooting Common Issues

  • Wrong chain: ensure eth_chainId returns 0x138de (mainnet) or 0x138c5 (Bepolia).
  • Hex quantities: send and parse 0x-prefixed hex strings (no leading zeros).
  • Timeouts/rate limits: implement retries with exponential backoff on HTTP 429 or -32005.

FAQs

  • Do I need an API key? Yes, append /YOUR_API_KEY to all endpoints.
  • WebSockets? Use HTTP endpoints above; WebSocket availability may vary.
  • Explorers/faucets? N/A.

Smoke Tests

  • curl: eth_blockNumber to both endpoints returns result: "0x...".
  • ethers v6: getBlockNumber() resolves; getNetwork().chainId equals 80094 or 80069.
  • web3.py: is_connected() is True; chain_id and block_number query succeed.

Start building on Berachain with Dwellir’s reliable RPC.