A centralized configuration package for Berachain networks, providing chain configurations, RPC URLs, and utility functions for both browser and Node.js environments.
# Core package
npm install @branch/rpc-config
# With viem support
npm install viem
# With ethers support
npm install ethersimport {
berachainMainnet,
berachainTestnet,
berachainLocalnet,
getChainById,
getChainByName,
} from "@branch/rpc-config";
// Use predefined chains
const mainnet = berachainMainnet;
const testnet = berachainTestnet;
const localnet = berachainLocalnet;
// Get chain by ID
const chain = getChainById(80085); // Returns berachainMainnet
// Get chain by name
const chainByName = getChainByName("berachain"); // Returns berachainMainnetFor browser-based applications, you can use either Viem or Ethers to create wallet connections:
// Using Viem
import { createBrowserWalletClient } from "@branch/rpc-config/viem";
import { berachainMainnet } from "@branch/rpc-config";
const browserWallet = createBrowserWalletClient({
chain: berachainMainnet,
// ... other options
});
// Using Ethers
import { createBrowserEthersSigner } from "@branch/rpc-config/ethers";
import { berachainMainnet } from "@branch/rpc-config";
const browserSigner = createBrowserEthersSigner({
chain: berachainMainnet,
// ... other options
});Security considerations for browser integration:
- Always use HTTPS in production
- Implement proper error handling for wallet connection failures
- Consider implementing wallet connection persistence
- Handle network switching gracefully
- Implement proper transaction confirmation handling
For scripts and backend services, you can use private key-based authentication:
// Using Viem
import { createBerachainWalletClient } from "@branch/rpc-config/viem";
import { berachainMainnet } from "@branch/rpc-config";
const walletClient = createBerachainWalletClient({
chain: berachainMainnet,
// ... other options
});
// Using Ethers
import { createBerachainEthersSigner } from "@branch/rpc-config/ethers";
import { berachainMainnet } from "@branch/rpc-config";
const signer = createBerachainEthersSigner({
chain: berachainMainnet,
// ... other options
});Security considerations for Node.js scripts:
- Never commit private keys to version control
- Use environment variables for sensitive data
- Implement proper error handling and retries
- Consider implementing transaction monitoring
- Use secure RPC endpoints
The package works with various development frameworks:
- Next.js: walletconnect-nextjs
- React Native: walletconnect-expo
- Vite: particle-auth-core-vite
- Chain ID: 80085
- RPC URL: https://rpc.berachain.com
- Block Explorer: https://berascan.com
- Currency: BERA
- Symbol: BERA
- Chain ID: 80085
- RPC URL: https://bepolia.rpc.berachain.com
- Block Explorer: https://bepolia.beratrail.io
- Currency: BERA
- Symbol: BERA
To add Berachain networks to MetaMask:
- Open MetaMask and click on the network selector dropdown
- Click "Add Network"
- Click "Add Network Manually"
- Use the network information from above to fill in the fields:
- For Mainnet, use the Berachain Mainnet details
- For Testnet, use the Bepolia Testnet details
- Click "Save"
This package is part of the Berachain Guides repository.