> For the complete documentation index, see [llms.txt](https://docs.everstake.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.everstake.com/integrations/everstake-products/wallet-sdk/protocols/berrachain.md).

# Berrachain

Learn how to integrate Berrachain staking via Everstake Wallet SDK.

## Getting Started <a href="#getting-started" id="getting-started"></a>

You can use this library to implement Berrachain staking for Everstake validator. Berrachain has EVM, so it works the same way as ethereum and you can use the same libraries for signing and sending tx. Also, you can use API for building transactions or fetching info.

**Option 1: REST API**

You can use REST API to call methods which are described in [Swagger](https://wallet-sdk-api.everstake.one/swagger/#/Berrachain) with detailed examples

```
https://wallet-sdk-api.everstake.one
```

**Option 2: JavaScript library**

You can install and import Wallet SDK for Javascript.

#### Step. 1: Installing the Library <a href="#step-1-installing-the-library" id="step-1-installing-the-library"></a>

Install the npm library or yarn by copying the code below.

{% tabs %}
{% tab title="npm" %}

```sh
$ npm install @everstake/wallet-sdk-berrachain
```

{% endtab %}

{% tab title="yarn" %}

```sh
$ yarn add @everstake/wallet-sdk-berrachain
```

{% endtab %}
{% endtabs %}

#### Step. 2: Import Wallet SDK <a href="#step-2-import-wallet-sdk" id="step-2-import-wallet-sdk"></a>

After installing the app, you can import module of needed blockchain (Ethereum, Aptos, Solana, Cosmos, Polygon are available) and use the SDK:

**Import ES6**

```javascript
// or you can also use
import * as Berrachain from '@everstake/wallet-sdk-berrachain';
// import needed class
import { Berrachain } from '@everstake/wallet-sdk-berrachain';
```

**Import ES5**

```javascript
// import module
const { Berrachain } = require("@everstake/wallet-sdk-berrachain");
// or you can also use
const { Berrachain } = require("@everstake/wallet-sdk-berrachain");
```

#### Step. 3: Create Berrachain instance <a href="#step-3-create-berrachain-instance" id="step-3-create-berrachain-instance"></a>

```javascript
const { Berrachain } = require("@everstake/wallet-sdk-berrachain");

// signet or mainnet
const network = 'testnet'

// public key from KeyPair. Buffer type
const publicKey = keyPair.publicKey

// rpc url
const rpc = 'https://some-berrachain-rpc.com'

const berrachain = new Berrachain(network, rpc);
```

## Getting Info  <a href="#getting-info-berrachain" id="getting-info-berrachain"></a>

* <mark style="color:yellow;">`balanceOf(address)`</mark>: Gets user's token balance by address.
* <mark style="color:yellow;">`getStake(address)`</mark>: Gets user's boosted balance by address.
* <mark style="color:yellow;">`getStakes(address)`</mark>: Gets all user's boost balances by address.
* <mark style="color:yellow;">`getStakeInQueue(address)`</mark>: Gets user's boost queue balance by address.

```javascript
const { Berrachain } = require("@everstake/wallet-sdk-berrachain");

// your staking address
const address = '0xC4F18e76693c271A64d8b93C4C65418085741aB4';

// create instance of Berrachain class
const berrachain = new Berrachain('testnet', 'https://your-rpc-instance.com');

console.log(await berrachain.balanceOf(address));
console.log(await berrachain.getStake(address));
console.log(await berrachain.getStakes(address));
console.log(await berrachain.getStakeInQueue(address));
```

## Stake <a href="#stake-bgt" id="stake-bgt"></a>

The <mark style="color:yellow;">`stake`</mark> method creates unsigned transaction for boosting (staking)

* <mark style="color:yellow;">`stake(address, amount)`</mark>: boost specific amount

```javascript
import {Berrachain} from '@everstake/wallet-sdk-berrachain';
import Web3 from 'web3';

const rpc = 'https://some-berrachain-rpc.com';
const privateKey = "1a...02";

const web3 = new Web3(rpc);

// your account
const account = web3.eth.accounts.privateKeyToAccount(privateKey);

// create instance of Berrachain class
const berrachain = new Berrachain('testnet', rpc);

// boost (stake) amount
const boostAmount = '0.00000001';

const txDetails = await bera.stake(account.address, boostAmount);
const nonce = await web3.eth.getTransactionCount(account.address);

const tx = { ...txDetails, nonce };
const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
if (signedTx.rawTransaction) {
    const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
    console.log("Transaction receipt:", receipt);
}
```

## Stake Activate <a href="#activate-stake-bgt" id="activate-stake-bgt"></a>

The <mark style="color:yellow;">`activateStake`</mark> method creates unsigned transaction for boost activation. It needs to do after boost.

* <mark style="color:yellow;">`activateStake(address, amount)`</mark>: activate boost

```javascript
import {Berrachain} from '@everstake/wallet-sdk-berrachain';
import Web3 from 'web3';

const rpc = 'https://some-berrachain-rpc.com';
const privateKey = "1a...02";

const web3 = new Web3(rpc);

// your account
const account = web3.eth.accounts.privateKeyToAccount(privateKey);

// create instance of Berrachain class
const berrachain = new Berrachain('testnet', rpc);

const txDetails = await bera.activateStake(account.address);
const nonce = await web3.eth.getTransactionCount(account.address);

const tx = { ...txDetails, nonce };
const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
if (signedTx.rawTransaction) {
    const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
    console.log("Transaction receipt:", receipt);
}
```

## Stake Cancel <a href="#cancel-stake-bgt" id="cancel-stake-bgt"></a>

The <mark style="color:yellow;">`cancelStake`</mark> method creates unsigned transaction for boost canceling

* <mark style="color:yellow;">`cancelStake(address, amount)`</mark>: cancel specific amount of boost

```javascript
import {Berrachain} from '@everstake/wallet-sdk-berrachain';
import Web3 from 'web3';

const rpc = 'https://some-berrachain-rpc.com';
const privateKey = "1a...02";

const web3 = new Web3(rpc);

// your account
const account = web3.eth.accounts.privateKeyToAccount(privateKey);

// create instance of Berrachain class
const berrachain = new Berrachain('testnet', rpc);

// boost (stake) amount for cancel
const boostAmount = '0.00000001';

const txDetails = await bera.cancelStake(account.address, boostAmount);
const nonce = await web3.eth.getTransactionCount(account.address);

const tx = { ...txDetails, nonce };
const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
if (signedTx.rawTransaction) {
    const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
    console.log("Transaction receipt:", receipt);
}
```

## Unstake Queue <a href="#queue-unstake-bgt" id="queue-unstake-bgt"></a>

The <mark style="color:yellow;">`queue unstake`</mark> method creates unsigned transaction for adding drop to a queue (unstake). It is a first step of unstaking process

* <mark style="color:yellow;">`queueUnstake(address, amount)`</mark>: queue drop (unstake) specific amount of boost

```javascript
import {Berrachain} from '@everstake/wallet-sdk-berrachain';
import Web3 from 'web3';

const rpc = 'https://some-berrachain-rpc.com';
const privateKey = "1a...02";

const web3 = new Web3(rpc);

// your account
const account = web3.eth.accounts.privateKeyToAccount(privateKey);

// create instance of Berrachain class
const berrachain = new Berrachain('testnet', rpc);

// drop (unstake) amount
const amount = '0.00000001';

const txDetails = await bera.queueUnstake(account.address, amount);
const nonce = await web3.eth.getTransactionCount(account.address);

const tx = { ...txDetails, nonce };
const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
if (signedTx.rawTransaction) {
    const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
    console.log("Transaction receipt:", receipt);
}
```

## Unstake Cancel <a href="#cancel-unstake-bgt" id="cancel-unstake-bgt"></a>

The <mark style="color:yellow;">`cancel unstake`</mark> method creates unsigned transaction for canceling drop from the queue (unstake). It can be canceled if address has not finished unstakes

* <mark style="color:yellow;">`cancelUnstake(address, amount)`</mark>: cancel drop (unstake) specific amount of boost from the queue

```javascript
import {Berrachain} from '@everstake/wallet-sdk-berrachain';
import Web3 from 'web3';

const rpc = 'https://some-berrachain-rpc.com';
const privateKey = "1a...02";

const web3 = new Web3(rpc);

// your account
const account = web3.eth.accounts.privateKeyToAccount(privateKey);

// create instance of Berrachain class
const berrachain = new Berrachain('testnet', rpc);

// drop (unstake) amount
const amount = '0.00000001';

const txDetails = await bera.cancelUnstake(account.address, amount);
const nonce = await web3.eth.getTransactionCount(account.address);

const tx = { ...txDetails, nonce };
const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
if (signedTx.rawTransaction) {
    const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
    console.log("Transaction receipt:", receipt);
}
```

## Confirm Unstake <a href="#unstake-bgt" id="unstake-bgt"></a>

The <mark style="color:yellow;">`unstake`</mark> method creates unsigned transaction for boost dropping

* <mark style="color:yellow;">`unstake(address, amount)`</mark>: drop (unstake) specific amount of boost

```javascript
import {Berrachain} from '@everstake/wallet-sdk-berrachain';
import Web3 from 'web3';

const rpc = 'https://some-berrachain-rpc.com';
const privateKey = "1a...02";

const web3 = new Web3(rpc);

// your account
const account = web3.eth.accounts.privateKeyToAccount(privateKey);

// create instance of Berrachain class
const berrachain = new Berrachain('testnet', rpc);

// drop (unstake) amount
const amount = '0.00000001';

const txDetails = await bera.unstake(account.address, amount);
const nonce = await web3.eth.getTransactionCount(account.address);

const tx = { ...txDetails, nonce };
const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
if (signedTx.rawTransaction) {
    const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
    console.log("Transaction receipt:", receipt);
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.everstake.com/integrations/everstake-products/wallet-sdk/protocols/berrachain.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
