Install BeraSig Extension
Connect BeraSig Wallet using ethers
Copy // Connect & get accounts
window . berasig . ethereum .request ({method : 'eth_accounts' });
// Alias for connection
window . berasig . ethereum .request ({method : 'eth_requestAccounts' });
Copy import { BrowserProvider } from 'ethers'
const provider = new BrowserProvider(window.berasig.ethereum)
const accounts = await provider.send('eth_requestAccounts', [])
const network = await provider.getNetwork()
const balance = await provider.getBalance(accounts[0])
Copy pnpm i @rainbow - me / rainbowkit@ 2 wagmi@ 2 viem@2.x
Copy pnpm i @tanstack / react - query
Copy import { createConfig , http , WagmiProvider } from "wagmi" ;
import { berachainTestnetbArtio } from "wagmi/chains" ;
import { berasigWallet } from "@rainbow-me/rainbowkit/wallets" ;
import {
ConnectButton ,
connectorsForWallets ,
RainbowKitProvider ,
} from "@rainbow-me/rainbowkit" ;
import { QueryClientProvider , QueryClient } from "@tanstack/react-query" ;
import "@rainbow-me/rainbowkit/styles.css" ;
// Define wallet connectors
const connectors = connectorsForWallets ([
{
groupName : "BeraChain" ,
wallets : [berasigWallet] ,
} ,
]);
// Configure Wagmi
const config = createConfig ({
connectors ,
chains : [berachainTestnetbArtio] ,
transports : {
[ berachainTestnetbArtio .id] : http () ,
} ,
});
// Initialize React Query Client
const queryClient = new QueryClient ();
// App Component
export default function App () {
return (
< WagmiProvider config = {config}>
< QueryClientProvider client = {queryClient}>
< RainbowKitProvider >
< ConnectButton />
</ RainbowKitProvider >
</ QueryClientProvider >
</ WagmiProvider >
);
}