stkBNB-web-sdk
SDK that makes integrating with stkBNB extremely easy.
Install
yarn
yarn add @persistenceone/stkbnb-web-sdk
npm
npm i @persistenceone/stkbnb-web-sdk
Docs
The docs are hosted at GitHub pages.
Usage
For detailed usage examples, please refer the docs on StkBNBWebSDK class . A few examples are given here:
Get stkBNB Balance
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance();
const user: string = '...'; // address of some user
const balance = await sdk.stkBNB.balanceOf(user);
console.log(`stkBNB.balanceOf(${user}) = ${StkBNBWebSDK.format(balance)} stkBNB`);
Stake
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
import { ethers } from 'ethers';
const sdk = StkBNBWebSDK.getInstance({ signerOrProvider: ... }); // just provide the signer here
const { transactionHash } = await sdk.stake(ethers.constants.WeiPerEther); // stake 1 BNB
Unstake
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
import { ethers } from 'ethers';
const sdk = StkBNBWebSDK.getInstance({ signerOrProvider: ... }); // just provide the signer here
const { transactionHash } = await sdk.unstake(ethers.constants.WeiPerEther); // unstake 1 stkBNB
Claim
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({ signerOrProvider: ... }); // just provide the signer here
const { transactionHash } = await sdk.claimAll(); // will claim all the requests for which cooldown period has finished