@ankr.com/staking-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.2.5 • Public • Published

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 - use REACT_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');

Readme

Keywords

none

Package Sidebar

Install

npm i @ankr.com/staking-sdk

Weekly Downloads

18

Version

1.2.5

License

MIT

Unpacked Size

824 kB

Total Files

136

Last publish

Collaborators

  • intoskai
  • nwts0as
  • ankr_network