---
updatedAt: 2026-03-03T12:12:19.000Z
agentTools:
  projectIndex: https://docs.stake.fish/llms.txt
---

# Babylon BABY

@stakefish/sdk-babylon-baby

The @stakefish/sdk-babylon-baby is a JavaScript/TypeScript library that provides a unified interface for staking operations on
the Babylon Baby blockchain with stake.fish validators. It allows developers to easily delegate stakes, undelegate,
redelegate, claim rewards, sign transactions, and broadcast them to the network.

## Table of Contents

* [Installation](#installation)
* [Type Imports](#type-imports)
* [API Reference](#api-reference)
  * [Constructor](#constructor)
  * [Delegation](#delegation)
  * [Undelegation](#undelegation)
  * [Redelegation](#redelegation)
  * [Claim Rewards](#claim-rewards)
  * [Signing](#signing)
  * [Broadcasting](#broadcasting)
* [Examples](#examples)
* [Notes](#notes)

## Installation

To use this SDK in your project, install it via npm or yarn:

```bash
npm install @stakefish/sdk-babylon-baby
```

```bash
yarn add @stakefish/sdk-babylon-baby
```

## Type Imports

```typescript
import { BabylonBaby } from '@stakefish/sdk-babylon-baby';
import type {
  BabylonBabyConfig,
  BabylonBabyPrepareDelegate,
  BabylonBabyPrepareUndelegate,
  BabylonBabyPrepareRedelegate,
  BabylonBabyPrepareClaimRewards,
  BabylonBabySign,
  BabylonBabyBroadcast,
  BabylonBabyUnsignedTransaction,
  BabylonBabySignedTransaction,
  BabylonBabyTransactionBroadcastResult,
} from '@stakefish/sdk-babylon-baby';
```

## API Reference

### Constructor

```typescript
import type { BabylonBabyConfig } from '@stakefish/sdk-babylon-baby';

new BabylonBaby({ rpcUrl: 'https://rpc.babylonchain.io', apiUrl: 'https://api.babylonchain.io', memo: 'Stake with stake.fish' }: BabylonBabyConfig)
```

Creates a new instance of the BabylonBaby SDK.

**Parameters:**

* `rpcUrl`: Babylon Baby RPC endpoint URL
* `apiUrl`: Babylon Baby API endpoint URL
* `memo`: Memo to include in transactions. This should be a unique string approved by stake.fish for your account.

### Delegation

```typescript
import type { BabylonBabyPrepareDelegate, BabylonBabyUnsignedTransaction } from '@stakefish/sdk-babylon-baby';

delegate({ delegatorAddress: 'bbn1...', amount: '1000000' }: BabylonBabyPrepareDelegate): Promise<BabylonBabyUnsignedTransaction>
```

Creates an unsigned transaction for delegating a specified amount of BABY tokens (in ubbn, the smallest unit) from the
delegator's address to the stake.fish validator.

**Parameters:**

* `delegatorAddress`: The Babylon Baby address of the delegator (e.g., 'bbn1...')
* `amount`: The amount to delegate in ubbn (1 BBN = 1,000,000 ubbn)

### Undelegation

```typescript
import type { BabylonBabyPrepareUndelegate, BabylonBabyUnsignedTransaction } from '@stakefish/sdk-babylon-baby';

undelegate({ delegatorAddress: 'bbn1...', amount: '1000000' }: BabylonBabyPrepareUndelegate): Promise<BabylonBabyUnsignedTransaction>
```

Creates an unsigned transaction for undelegating a specified amount from the stake.fish validator.

**Parameters:**

* `delegatorAddress`: The Babylon Baby address of the delegator (e.g., 'bbn1...')
* `amount`: The amount to undelegate in ubbn (1 BBN = 1,000,000 ubbn)

### Redelegation

```typescript
import type { BabylonBabyPrepareRedelegate, BabylonBabyUnsignedTransaction } from '@stakefish/sdk-babylon-baby';

redelegate({ delegatorAddress: 'bbn1...', srcValidatorAddress: 'bbnvaloper1...', amount: '1000000' }: BabylonBabyPrepareRedelegate): Promise<BabylonBabyUnsignedTransaction>
```

Creates an unsigned transaction for redelegating a specified amount from a source validator to the stake.fish validator.

**Parameters:**

* `delegatorAddress`: The Babylon Baby address of the delegator (e.g., 'bbn1...')
* `srcValidatorAddress`: The validator address to redelegate from (e.g., 'bbnvaloper1...')
* `amount`: The amount to redelegate in ubbn (1 BBN = 1,000,000 ubbn)

### Claim Rewards

```typescript
import type { BabylonBabyPrepareClaimRewards, BabylonBabyUnsignedTransaction } from '@stakefish/sdk-babylon-baby';

claimRewards({ delegatorAddress: 'bbn1...' }: BabylonBabyPrepareClaimRewards): Promise<BabylonBabyUnsignedTransaction>
```

Creates an unsigned transaction for claiming staking rewards from the stake.fish validator.

**Parameters:**

* `delegatorAddress`: The Babylon Baby address of the delegator (e.g., 'bbn1...')

### Signing

```typescript
import type { BabylonBabySign, BabylonBabyUnsignedTransaction, BabylonBabySignedTransaction } from '@stakefish/sdk-babylon-baby';

sign({ privateKeyHex: '0x...', unsignedTx }: BabylonBabySign): Promise<BabylonBabySignedTransaction>
```

Signs the unsigned transaction using the provided private key. This operation works completely offline and does not
require network connectivity.

**Parameters:**

* `privateKeyHex`: The private key in hexadecimal format (with or without '0x' prefix)
* `unsignedTx`: The unsigned transaction object from `delegate()`, `undelegate()`, `redelegate()`, or `claimRewards()`

### Broadcasting

```typescript
import type { BabylonBabyBroadcast, BabylonBabySignedTransaction, BabylonBabyTransactionBroadcastResult } from '@stakefish/sdk-babylon-baby';

broadcast({ signedTx, checkInclusion: true, timeoutMs: 60000, pollIntervalMs: 2000 }: BabylonBabyBroadcast): Promise<BabylonBabyTransactionBroadcastResult>
```

Broadcasts the signed transaction to the Babylon Baby network and optionally waits for inclusion confirmation.

**Parameters:**

* `signedTx`: The signed transaction object from `sign()`
* `checkInclusion` (optional): Whether to wait for transaction inclusion (default: `true`)
* `timeoutMs` (optional): Maximum time to wait for inclusion in milliseconds (default: `60000`)
* `pollIntervalMs` (optional): Interval between inclusion checks in milliseconds (default: `2000`)

**Returns:** `BabylonBabyTransactionBroadcastResult` object containing:

* `txId`: The transaction hash
* `success`: Boolean indicating if the transaction was successful
* `error`: Error message if the transaction failed (optional)

## Examples

### Full delegation example

```typescript
import { BabylonBaby } from '@stakefish/sdk-babylon-baby';
import type {
  BabylonBabyUnsignedTransaction,
  BabylonBabySignedTransaction,
  BabylonBabyTransactionBroadcastResult,
} from '@stakefish/sdk-babylon-baby';

const delegator = process.env.BABYLON_BABY_ADDRESS;
const rpcUrl = process.env.BABYLON_BABY_RPC;
const privateKeyHex = process.env.BABYLON_BABY_PRIVATE_KEY;

async function main() {
  const babylonBaby = new BabylonBaby({
    rpcUrl: rpcUrl,
    apiUrl: rpcUrl,
    memo: 'Stake with stake.fish',
  });

  // Delegation (1 BBN = 1,000,000 ubbn)
  const unsignedTx: BabylonBabyUnsignedTransaction = await babylonBaby.delegate({
    delegatorAddress: delegator,
    amount: '1000000',
  });

  // Sign
  const signedTx: BabylonBabySignedTransaction = await babylonBaby.sign({ privateKeyHex, unsignedTx });

  // Broadcast
  const result: BabylonBabyTransactionBroadcastResult = await babylonBaby.broadcast({ signedTx });
  console.log('Broadcast result:', JSON.stringify(result));
}

void main().catch(console.error);
```

### Undelegation

Undelegation amount must match the full amount delegated.

```typescript
const unsignedTx: BabylonBabyUnsignedTransaction = await babylonBaby.undelegate({
  delegatorAddress: delegator,
  amount: '1000000',
});
```

### Redelegation

```typescript
const unsignedTx: BabylonBabyUnsignedTransaction = await babylonBaby.redelegate({
  delegatorAddress: delegator,
  srcValidatorAddress: 'bbnvaloper1...',
  amount: '1000000',
});
```

### Claim Rewards

```typescript
const unsignedTx: BabylonBabyUnsignedTransaction = await babylonBaby.claimRewards({
  delegatorAddress: delegator,
});
```

### Configuration

The SDK requires configuration during instantiation with RPC and API endpoints:

```typescript
const babylonBaby = new BabylonBaby({
  rpcUrl: 'https://custom-rpc.babylon.network',
  apiUrl: 'https://custom-api.babylon.network',
  memo: 'Stake with stake.fish',
});
```

## Notes

* All amounts in the SDK are specified in ubbn, the smallest unit of BBN (1 BBN = 1,000,000 ubbn)
* The SDK automatically handles gas estimation and fee calculation for transactions
* Private keys can be provided in hexadecimal format with or without the '0x' prefix
* Private keys should be kept secure and never committed to version control
* The SDK targets Babylon Baby (bbn-1) mainnet