Getting Started
You can use this library to implement Babylon staking for Everstake validator.
Step. 1: Installing the Library
Install the npm library by copying the code below.
sh
$ npm install @everstake/wallet-sdk
or you can also use yarn
sh
$ yarn add @everstake/wallet-sdk
Step. 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
js
// or you can also use
import * as Babylon from '@everstake/wallet-sdk/babylon';
// import needed class
import { Babylon } from '@everstake/wallet-sdk/babylon';
Import ES5
js
// import module
const { Babylon } = require("@everstake/wallet-sdk");
// or you can also use
const { Babylon } = require("@everstake/wallet-sdk/babylon");
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.
js
// import
const { CreateToken } = require("@everstake/wallet-sdk");
// Project name
const name = 'Everstake Wallet SDK';
// wallet | Dapp | Other
const type = 'SDK';
// Create Token - return token ID
const token = await CreateToken(name, type);
console.log(token); // 3155f389-d943-4966-8e18-f159c2a6ef66
Step. 4: Create Babylon instance
js
const { Babylon } = require("@everstake/wallet-sdk/babylon");
// signet or mainnet
const network = 'signet'
// public key from KeyPair. Buffer type
const publicKey = keyPair.publicKey
const babylon = new Babylon(network, publicKey, 'YOUR_TOKEN');
Example of using keyPair to get public key and address (signet)
js
const bitcoin = require('bitcoinjs-lib');
const ecc = require('tiny-secp256k1'); // For elliptic curve operations
const {ECPairFactory} = require('ecpair')
const ECPair = ECPairFactory(ecc);
// Taproot requires tiny-secp256k1 for ECC operations
bitcoin.initEccLib(ecc);
const signetNetwork = { // or use from bitcoin.networks.testnet
messagePrefix: '\x18Bitcoin Signed Message:\n',
bech32: 'tb', // Bech32 prefix (same as Testnet, even for Signet)
bip32: {
public: 0x043587cf,
private: 0x04358394,
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef,
};
const privateKey = 'XXXXXXXXXXXXqdUAXbpr92hF7M28kTsXXXXXXXXXXXXX'
const keyPair = ECPair.fromWIF(privateKey, signetNetwork)
// Taproot address generation (using single public key)
const { address } = bitcoin.payments.p2tr({
internalPubkey: keyPair.publicKey.slice(1, 33), // Remove prefix byte
network: signetNetwork,
});
console.log('address:', address);