Staking

APIs for staking ADA and managing stake pools.

Delegate ADA to Stakepool

Delegation is the process by which ADA holders delegate the stake associated with their ADA to a stake pool. Doing so, this allows ADA holders to participate in the network and be rewarded in proportion to the amount of stake delegated.

import { Transaction } from '@meshsdk/core';

const rewardAddress = 'stake1qdzmqvfdnxsn4a3hd57x435madswynt4hqw8n7f2pdq05g4995re';
const poolId = 'pool1mhww3q6d7qssj5j2add05r7cyr7znyswe2g6vd23anpx5sh6z8d';

const tx = new Transaction({ initiator: wallet });
tx.delegateStake(rewardAddress, poolId);

const unsignedTx = await tx.build();
const signedTx = await wallet.signTx(unsignedTx);
const txHash = await wallet.submitTx(signedTx);
No wallets installed

Register Stake Address

New address must "register" before they can delegate to stakepools. To check if a reward address has been register, use blockchainProvider.fetchAccountInfo(rewardAddress). For example this account information, active shows the address is registered.

{
  "active": true,
  "poolId": "pool1mhww3q6d7qssj5j2add05r7cyr7znyswe2g6vd23anpx5sh6z8d",
  "balance": "389290551",
  "rewards": "0",
  "withdrawals": "0"
}

You can chain with delegateStake() to register and delegate to a stake pool.

import { Transaction } from '@meshsdk/core';

const rewardAddress = 'stake1qdzmqvfdnxsn4a3hd57x435madswynt4hqw8n7f2pdq05g4995re';
const poolId = 'pool1mhww3q6d7qssj5j2add05r7cyr7znyswe2g6vd23anpx5sh6z8d';

const tx = new Transaction({ initiator: wallet });
tx.registerStake(rewardAddress);
tx.delegateStake(rewardAddress, poolId);

const unsignedTx = await tx.build();
const signedTx = await wallet.signTx(unsignedTx);
const txHash = await wallet.submitTx(signedTx);
No wallets installed