# Wallet integration

## Install BeraSig Extension

The first thing you need to do is install the BeraSig Extension if you don't have it. You can find it here <https://chromewebstore.google.com/detail/berasig/ckedkkegjbflcfblcjklibnedmfjppbj>

## Connect BeraSig Wallet using ethers

```javascript
// Connect & get accounts
window.berasig.ethereum.request({method: 'eth_accounts'});
// Alias for connection
window.berasig.ethereum.request({method: 'eth_requestAccounts'});
```

```javascript
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])
```

## Connect BeraSig Wallet using [rainbowkit](https://www.rainbowkit.com/)

1. Ensure that you are using the latest versions of RainbowKit, Wagmi, and Viem

<pre class="language-powershell"><code class="lang-powershell"><strong>pnpm i @rainbow-me/rainbowkit@2 wagmi@2 viem@2.x
</strong></code></pre>

2. Since Wagmi v2 requires TanStack Query as a peer dependency, install it using the command below:

```powershell
pnpm i @tanstack/react-query
```

3. Here is an example configuration to integrate BerasigWallet with RainbowKit:

```typescript
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>
  );
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://berasig.gitbook.io/berasig-docs/wallet-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
