@ankr.com/staking-sdk
v1.2.5
Published
### Install
Downloads
120
Readme
staking-sdk
Install
# yarn
yarn add @ankr.com/staking-sdk reselect
# npm
npm i @ankr.com/staking-sdk reselect
To choose testsnet contracts use
REACT_APP_API_ENV=staging
environment variable. For mainnet - useREACT_APP_API_ENV=prod
.
Examples of usage:
Here is a codesandbox sample how to get balance using @ankr.com/staking-sdk
https://codesandbox.io/s/ankr-staking-sdk-e1jvvi
// stake aMATICc token
import { PolygonOnEthereumSDK } from '@ankr.com/staking-sdk';
const sdk = await PolygonOnEthereumSDK.getInstance();
const { txHash } = await sdk.stake(new BigNumber(1_200), 'aMATICc');
// unstake aMATICc token
import { PolygonOnEthereumSDK } from '@ankr.com/staking-sdk';
const sdk = await PolygonOnEthereumSDK.getInstance();
await sdk.unstake(new BigNumber(1_200), 'aMATICc');
// switch aMATICb and aMATICc
import { PolygonOnEthereumSDK } from '@ankr.com/staking-sdk';
const sdk = await PolygonOnEthereumSDK.getInstance();
const lockResponse = await sdk.lockShares({ amount: new BigNumber(2.65) });
const unlockResponse = await sdk.unlockShares({ amount: new BigNumber(1.98) });
// Get MATIC transaction history
import { PolygonOnEthereumSDK } from '@ankr.com/staking-sdk';
const sdk = await PolygonOnEthereumSDK.getInstance();
const history = await sdk.getTxEventsHistory();
// stake aBNBc token
import { BinanceSDK } from '@ankr.com/staking-sdk';
const sdk = await BinanceSDK.getInstance();
const { txHash } = await sdk.stake(new BigNumber(1_200), 'aBNBc');
// unstake aBNBc token
import { BinanceSDK } from '@ankr.com/staking-sdk';
const sdk = await BinanceSDK.getInstance();
await sdk.unstake(new BigNumber(1_200), 'aBNBc');
// switch aBNBb and aBNBc
import { BinanceSDK } from '@ankr.com/staking-sdk';
const sdk = await BinanceSDK.getInstance();
const lockResponse = await sdk.lockShares({ amount: new BigNumber(2.65) });
const unlockResponse = await sdk.unlockShares({ amount: new BigNumber(1.98) });
// Get BNB transaction history
import { BinanceSDK } from '@ankr.com/staking-sdk';
const sdk = await BinanceSDK.getInstance();
const history = await sdk.getTxEventsHistory();
// stake aETHc token
import { EthereumSDK } from '@ankr.com/staking-sdk';
const sdk = await EthereumSDK.getInstance();
const { txHash } = await sdk.stake(new BigNumber(1_200), 'aETHc');
// switch aETHc and aETHb
import { EthereumSDK } from '@ankr.com/staking-sdk';
const sdk = await EthereumSDK.getInstance();
const lockResponse = await sdk.lockShares({ amount: new BigNumber(2.65) });
const unlockResponse = await sdk.unlockShares({ amount: new BigNumber(1.98) });
// User defined providers
import { PolygonOnEthereumSDK, Web3KeyReadProvider, Web3KeyWriteProvider } from '@ankr.com/staking-sdk';
const readProvider: Web3KeyReadProvider = { ... };
const writeProvider: Web3KeyWriteProvider = { ... };
const sdk = await PolygonOnEthereumSDK.getInstance({ readProvider, writeProvider });
const { txHash } = await sdk.stake(new BigNumber(1_200), 'aMATICc');