Getting Started
The Cardano wallet SDK library provides class with batch of methods that helps to manage user's stake.
Install the npm library by copying the code below.
$ npm install @everstake/wallet-sdk-cardano
or you can also use yarn
$ yarn add @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.
await cardano.selectPool(); // preloaded
const tx = await registerTx() // selectPool() will skipped