Documentation v1.0 has been released! Staking Guide, Protocols, Glossary, FAQ, and Support sections have been added.

Cardano

Learn how to integrate Cardano staking into your app using Everstake Wallet SDK.

Getting Started

The Cardano wallet SDK library provides class with batch of methods that helps to manage user's stake.

Install the npm library or yarn by copying the code below.

$ npm install @everstake/wallet-sdk-cardano

This code example how to make Cardano instance. The base account should be in correct format - bech32. To create instance also need to get a blockFrostProjectID. More details can be found here https://blockfrost.io/ . Be careful when use network. (preview and preprod are testnets). All code examples use meshjs library, but it's not required to reuse.

import {CardanoWeb3} from "cardano-web3-js"
import {Cardano} from "@everstake/wallet-sdk-cardano";

import {Cardano} from "@everstake/wallet-sdk-cardano";
import {BlockfrostProvider, MeshWallet} from "@meshsdk/core";

const blockFrostID = '...';
const mnemonic = '...';
const network = 'preview';
const networkID = 0;

const cardano = new Cardano(network, paymentWallet.addresses.baseAddressBech32!, blockFrostID);
await cardano.init();

cardano.init() must be called. it will not work without that.

(Optionally) Methods stake(), registerTx() and delegateTx() required information about pool. It automatically calls selectPool() methods, that is a bit slowly. But it can be preloaded if selectPool() will be lazy loaded before delegations methods to save some time.

Stake

The stakeTx method creates unsigned transaction for register stake account, delegate to staking pool and vote for DRep.

Also, an alternative option it can be called as separate methods.

Unstake

The deregisterTx method creates unsigned transaction for deregistration stake. This method returns pledge (2 ADA) + stake (delegation) + rewards. So no need to claim rewards additionally.

Get Info

Method getStakeInfo shows information about current stake. undefined value means that account is not registered.

Method getDelegations shows list of delegations of current account.

Method getStakeActivation shows more information about delegation status and time to active stake.

Method getRewardHistory shows users rewards history per epochs.

Method getPoolsInfos returns info about specified pools.

Method getPoolIDs returns list of internal pools.

Method isInternalPoolDelegation returns boolean value that shows is current pool delegation is to internal pool.

Withdraw Rewards

The withdrawRewardsTx method creates unsigned transaction for withdraw rewards. Cardano has auto compound strategy, so it means no need claim rewards to increase APR. But if rewards should be spent need to call withdraw or deregister method.