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.
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
https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY
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
- cURL
- Ethers.js v6
- Viem
- Python (web3.py)
# 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}'
import { JsonRpcProvider } from 'ethers';
// Mainnet
const mainnet = new JsonRpcProvider('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY');
console.log(await mainnet.getBlockNumber());
console.log((await mainnet.getNetwork()).chainId); // 80094
// Bepolia testnet
const bepolia = new JsonRpcProvider('https://api-berachain-bepolia.n.dwellir.com/YOUR_API_KEY');
console.log(await bepolia.getBlockNumber());
console.log((await bepolia.getNetwork()).chainId); // 80069
import { createPublicClient, http, parseEther } from 'viem';
const mainnet = createPublicClient({
transport: http('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY'),
});
const blockNumber = await mainnet.getBlockNumber();
const balance = await mainnet.getBalance({ address: '0x0000000000000000000000000000000000000000' });
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY'))
assert w3.is_connected()
print(w3.eth.chain_id) # 80094
print(w3.eth.block_number)
Network Information
Mainnet Chain ID
80094 (0x138de)
Berachain MainnetTestnet Chain ID
80069 (0x138c5)
Bepolia TestnetRPC Standard
Ethereum JSON-RPC 2.0
EVM-compatibleJSON-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:
- Update RPC URL to Berachain: https://api-berachain-mainnet.n.dwellir.com/YOUR_API_KEY
- Verify chain ID via
eth_chainId
(0x138de mainnet) before sending transactions - Re-check gas settings (EIP‑1559) and any hard‑coded addresses
// 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
- Berachain Docs: https://docs.berachain.com/
- Dwellir Dashboard (API keys, usage): https://dashboard.dwellir.com
- Dwellir Support: support@dwellir.com
Troubleshooting Common Issues
- Wrong chain: ensure
eth_chainId
returns0x138de
(mainnet) or0x138c5
(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 returnsresult: "0x..."
. - ethers v6:
getBlockNumber()
resolves;getNetwork().chainId
equals 80094 or 80069. - web3.py:
is_connected()
is True;chain_id
andblock_number
query succeed.
Start building on Berachain with Dwellir’s reliable RPC.