Private constructorPrivate Readonly _numPrivate Readonly _signerPrivate Readonly _stakePrivate Readonly _stkBNBPrivate Readonly _subgraphsubgraph url
Check if a particular claim request for the signer can be claimed instantly.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
const yesOrNo = await sdk.canBeClaimedInstantly(0); // check the claim request at index 0
A promise that resolves to a boolean value indicating if the claim request can be claimed instantly.
Index of the claim request to be claimed for that specific user.
Claim a particular claim request for the signer.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
const { transactionHash } = await sdk.claim(0); // claim the request at index 0
A transaction receipt for the interaction with the contract
Index of the claim request to be claimed
Optional overrides: Overrides & { Claims all the claim requests for the signer.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
const { transactionHash } = await sdk.claimAll();
A transaction receipt for the interaction with the contract
Optional overrides: Overrides & { Converts stkBNB to BNB based on the current exchange rate in the contract.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
import { ethers } from 'ethers';
const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
const exchangeRate = await sdk.convertToBNB(ethers.constants.WeiPerEther); // find how much 1 stkBNB is worth
console.log(`1 stkBNB = ${StkBNBWebSDK.format(exchangeRate)} BNB`); // 1 stkBNB = 1.004202 BNB
The BNB equivalent of the given amount
Amount of stkBNB to convert to BNB
Converts BNB to stkBNB based on the current exchange rate in the contract.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
import { ethers } from 'ethers';
const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
const exchangeRate = await sdk.convertToStkBNB(ethers.constants.WeiPerEther); // find how much 1 BNB is worth
console.log(`1 BNB = ${StkBNBWebSDK.format(exchangeRate)} stkBNB`); // 1 BNB = 0.995815 stkBNB
The stkBNB equivalent of the given amount
Amount of BNB to convert to stkBNB
Fetches APR% for n number of days before.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
const apr = await sdk.getApr(7); // get apr% between current Exchange rate and 7 days before exchange rate.
APR% between current and n days before exchange rate.
Number of days for calculating APR.
Get the current unlock period for the claims.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
const cooldownPeriodInSeconds = await sdk.getClaimUnlockTime(); // how many seconds need to pass for claim to be unlocked
Fetches all the claim requests for the user.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
const claimRequests = await sdk.getClaims('0xa8E41F290ECfe99488D2F5f6621daf36a592e1D7'); // get all the claim requests for the address 0xa8E41F290ECfe99488D2F5f6621daf36a592e1D7
An array containing all the claim requests for the user
The address of the user to query
Get the number of claims for the current user.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
const numberOfClaims = await sdk.getClaimsLength(); // you get the number of claims for the current user
A promise that resolves to the number of claims for the current user.
Get the available amount for instant claim requests.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // provide at least the provider
const weiAvailable = await sdk.getInstantClaimAvailableAmount();
A promise that resolves to the available wei amount for instant claim requests.
Fetches the current TVL (total value locked), aka TVU (total value unlocked)
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
const tvl = await sdk.getTvl();
console.log(`TVL = ${StkBNBWebSDK.format(tvl, 2)} BNB`); // TVL = 25229.76 BNB
The current TVL
Claim a particular claim request for the signer instantly. Deducts a fee.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
const { transactionHash } = await sdk.instantClaim(0); // claim the request at index 0
A transaction receipt for the interaction with the contract
Optional overrides: Overrides & { Stake BNB for the signer.
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
A transaction receipt for the interaction with the contract
Amount of BNB to stake
Optional overrides: Overrides & { Unstake BNB for the signer. The unstaked amount will be available to claim after the cooldown period is over.
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
A transaction receipt for the interaction with the contract
Amount of stkBNB to unstake
Optional overrides: Overrides & { Static formatRounds an 18 decimal token balance value to 6 digits of precision to show in the UI.
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
import { ethers } from 'ethers';
const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
const exchangeRate = await sdk.convertToBNB(ethers.constants.WeiPerEther); // find how much 1 stkBNB is worth
console.log(`1 stkBNB = ${StkBNBWebSDK.format(exchangeRate)} BNB`); // 1 stkBNB = 1.004202 BNB
The formatted value with 6 digits of precision.
The value to format
The number of decimals to show in the UI
Static getGet a new instance of the sdk. Any transactions initiated by this instance will wait for the transaction to finalize as per the configured opts.numConfirmations.
// Get the testnet instance:
import { StkBNBWebSDK, Env } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance({env: Env.Testnet});
// OR get the mainnet instance for reading the blockchain:
import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
const sdk = StkBNBWebSDK.getInstance();
// OR get the mainnet instance for carrying out transactions:
import { StkBNBWebSDK, MAINNET_CONFIG } from "@persistenceone/stkbnb-web-sdk";
import { ethers } from 'ethers';
const provider = MAINNET_CONFIG.defaultProvider; // or use your own JSON RPC provider
const wallet = ethers.Wallet.fromMnemonic('...').connect(provider); // or use your existing wallet instance
const sdk = StkBNBWebSDK.getInstance({signerOrProvider: wallet}); // just provide the signer here
Optional opts: OptionsGenerated using TypeDoc
The main sdk API.