# 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
.
Here is a codesandbox sample how to get balance using @ankr.com/staking-sdk
https://codesandbox.io/s/ankr-staking-sdk-e1jvvi
// stake ankrMATIC token
import { PolygonOnEthereumSDK } from '@ankr.com/staking-sdk';
const sdk = await PolygonOnEthereumSDK.getInstance();
const { txHash } = await sdk.stake(new BigNumber(1_200), 'ankrMATIC');
// unstake ankrMATIC token
import { PolygonOnEthereumSDK } from '@ankr.com/staking-sdk';
const sdk = await PolygonOnEthereumSDK.getInstance();
await sdk.unstake(new BigNumber(1_200), 'ankrMATIC');
// switch aMATICb and ankrMATIC
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.getTxHistoryRange(from, to);
// 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.getTxHistoryRange(from, to);
// 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), 'ankrMATIC');
Generated using TypeDoc