Learn how to integrate Cosmos staking into Everstake Wallet SDK apps.
Getting Started
You can use two different options to implement staking for Everstake validator.
Option 1: REST API
You can use REST API to call methods which are described in Swagger with detailed examples
https://wallet-sdk-api.everstake.one
Option 2: JavaScript library
You can install and import Wallet SDK for Javascript.
Step. 1: Installing the Library
Install the npm library or yarn by copying the code below.
$npminstall@everstake/wallet-sdk
$yarnadd@everstake/wallet-sdk
Step. 2: Import Wallet SDK
After installing the app, you can import module of needed blockchain (Ethereum, Aptos, Solana, Cosmos, Polygon are available) and use the SDK:
Import ES6
Import ES5
Step. 3: Create Auth Token
In order to access all the features of the Wallet SDK, it's necessary for you to generate an authentication token. This token will be required in all of the methods you use.
// import module
import { Cosmos } from '@everstake/wallet-sdk';
// or you can also use
import * as Cosmos from '@everstake/wallet-sdk/cosmos';
// import needed function
import { delegate } from '@everstake/wallet-sdk/cosmos';
// import module
const { Cosmos } = require("@everstake/wallet-sdk");
// or you can also use
const { delegate } = require("@everstake/wallet-sdk/cosmos");
// import
const { CreateToken } = require("@everstake/wallet-sdk");
// Project name
const name = 'Everstake Wallet SDK';
// wallet | Dapp | Other
const type = 'SDK';
// Create Token - return token ID
const token = await CreateToken(name, type);
console.log(token); // 3155f389-d943-4966-8e18-f159c2a6ef66
// Import SDK
import { Cosmos } from '@everstake/wallet-sdk';
// User wallet address.
const address = 'examplecosmos1hgmhc4hajlh8u47wmmls6ze4yrfekhs';
// Get all user delegation.
const getDelegationsResult = await Cosmos.getDelegations(address);
console.log(getDelegationsResult); // see the response below
getDelegationsResult = {
"result": [
{
"delegation": {
"delegator_address": "cosmos1hgmhc4hajlh8u47wmmls6ze4yrfekhs6ujz05e",
"validator_address": "cosmosvaloper1ptyzewnns2kn37ewtmv6ppsvhdnmeapvtfc9y5",
"shares": "1000.000000000000000000"
},
"balance": {
"denom": "uatom",
"amount": "1000"
},
"operator_address": "cosmosvaloper1ptyzewnns2kn37ewtmv6ppsvhdnmeapvtfc9y5",
"consensus_pubkey": {
"type": "tendermint/PubKeyEd25519",
"value": "XiGz/D6eg3KdjaFB0uYIJwkOTW5xZcFRxJmHcQYB3zg="
},
"status": 3,
"tokens": "513203840253",
"delegator_shares": "513203840253.000000000000000000",
"description": {
"moniker": "WeStaking",
"identity": "DA9C5AD3E308E426",
"website": "https://www.westaking.io",
"details": "Delegate your atom to us for the staking rewards. We will do our best as secure and stable validator."
},
"unbonding_time": "2019-09-07T12:24:58.270714195Z",
"commission": {
"commission_rates": {
"rate": "0.030000000000000000",
"max_rate": "0.200000000000000000",
"max_change_rate": "0.010000000000000000"
},
"update_time": "2020-03-29T00:37:22.163935678Z"
},
"min_self_delegation": "1"
},
{
"delegation": {
"delegator_address": "cosmos1hgmhc4hajlh8u47wmmls6ze4yrfekhsexample",
"validator_address": "cosmosvaloper1tflk30mq5vgqjdly92kkhhq3raev2hnz6eete3",
"shares": "2000.000000000000000000"
},
"balance": {
"denom": "uatom",
"amount": "2000"
},
"operator_address": "cosmosvaloper1tflk30mq5vgqjdly92kkhhq3raev2hnz6eete3",
"consensus_pubkey": {
"type": "tendermint/PubKeyEd25519",
"value": "dhhD3I5QbtC870Il4IzML5Q2AwVDiSn9/HJ9w09Rgdg="
},
"status": 3,
"tokens": "7087394678764",
"delegator_shares": "7087394678764.000000000000000000",
"description": {
"moniker": "Everstake",
"identity": "EF5AC70C00BECEDC",
"website": "https://everstake.one",
"details": "Reliable and experienced staking service provider from Ukraine. Visit our website for more details."
},
"unbonding_time": "2019-12-07T19:10:59.878559804Z",
"commission": {
"commission_rates": {
"rate": "0.060000000000000000",
"max_rate": "0.200000000000000000",
"max_change_rate": "0.010000000000000000"
},
"update_time": "2022-12-31T22:25:10.09405574Z"
},
"min_self_delegation": "1"
}
]
}
// Import SDK
import { Cosmos } from '@everstake/wallet-sdk';
// User wallet address.
const address = 'cosmos176f4pukjdnsjmvwsngxa6re8r50rkuf7dya90m';
// Get all user delegation.
const getUndelegationsResult = await Cosmos.getUndelegations(address);
console.log(getUndelegationsResult); // see the response below