Babylon
Learn how to add Babylon staking support using Everstake Wallet SDK.
Getting Started
You can use this library or API to implement Babylon staking for Everstake validator.
As an example we use:
node: v22.11.0
bitcoinjs-lib: ^6.1.5
ecpair: ^2.1.0
tiny-secp256k1: ^2.2.3
@everstake/wallet-sdk: v0.*
Step. 1: Installing the Library
Install the npm library or yarn by copying the code below.
$ npm install @everstake/wallet-sdk$ yarn add @everstake/wallet-sdkStep. 2: Import Wallet SDK
After installing the app, you can import module of needed blockchain (Ethereum, Aptos, Solana, Cosmos, Polygon are available) and use the SDK:
Import ES6
Import ES5
Step. 3: Create Auth Token
In order to access all the features of the Wallet SDK, it's necessary for you to generate an authentication token. This token will be required in all of the methods you use.
Step. 4: Create Babylon instance
Example of using keyPair to get public key and address (signet)
Example of using PSBT API
Stake
The stake method creates unsigned transaction for stake/delegation
stake(amount, feeRate = 1): Stake bitcoin stats from and for specific address. Min. stake is 0.0005 BTC
Unstake
The unbonding method creates unsigned transaction for unbonding (undelegation which need to withdraw then)
unbonding(stakingTxHash): Unbond stake from specific staking Tx.
Unbonding using API
At first, you need use /babylon/unbonding endpoint to create unbonding tx, then you need to sign this transaction and make a payload which need to send to another endpoint /babylon/unbonding/send to make order for unbonding.
Withdraw
There are at least two types of withdrawing:
withdrawEarlyUnbonded(stakingTxHash, feeRate = 1): withdraw your stake after unbondingwithdrawTimelockUnbonded(stakingTxHash, feeRate = 1): withdraw your stake after your stake period is expired. No need to make unbonding before
Getting Info
getDelegations(): Gets all user's delegations using the current public key.getGlobalParamsVersions(): Gets all versions of global params.

