2.0.3 • Published 3 years ago

@ankr.com/stkr-jssdk-v2 v2.0.3

Weekly downloads
10
License
MIT
Repository
-
Last release
3 years ago

Ankr Staking JavaScript SDK

This sdk used to implement stkr.io to javascript applications.

Installation

Via npm;

npm install @ankr.com/stkr-jssdk-v2

Via yarn;

yarn add @ankr.com/stkr-jssdk-v2

Usage

Stkr sdk constructor gets web3 instance and network name (e.g. mainnet or goerli) and act like a bridge to contract with web3. And return types almost same with web3 contract calls but they may be changed / edited to provide simplicity for applications.

You can configure Stkr SDK instance by setting env REACT_APP_STKR_ENV to one of next possible values:

  • mainnet (default) - use mainnet configuration
  • goerli - use goerli configuration
  • develop - use develop configuration
  • local - use localhost configuration
import { StkrSdk } from "@ankr.com/stkr-jssdk-v2"
const stkr = StkrSdk.getForEnv()
await stkr.connect()
const {transactionHash} = await stkr.stake('1')
await stkr.disconnect()

Or if you want you can also configure Stkr SDK instance manually.

import { StkrSdk } from "@ankr.com/stkr-jssdk-v2"
const stkr = StkrSdk.getForConfig({
  // ...
})
await stkr.connect()
const {transactionHash} = await stkr.stake('1')
await stkr.disconnect()