Staking
This section covers the operations for staking your wallet on the Cardano network.
Register stake key
When registering a stake key with the Cardano network, a deposit of 2 ADA
is required. This deposit acts as a pledge and is temporarily deducted from the wallet balance.
const tx = await lucid.newTx().registerStake(rewardAddress).complete();
💡
Query the reward address (stake_...
) of the selected wallet:
const rewardAddress = await lucid.wallet().rewardAddress();
Delegate to a stake pool
Delegating to a stake pool involves associating your stake key with a pool identified by its unique ID.
const tx = await lucid
.newTx()
.delegateTo(rewardAddress, "poolabc...")
.complete();
You can combine both registration and delegation into a single transaction:
const tx = await lucid
.newTx()
.registerAndDelegate.ToPool(rewardAddress, "poolabc...")
.complete();
Withdraw rewards
Allows the wallet holder to claim any rewards accumulated through staking. The rewards are withdrawn to the wallets balance.
const delegation = await lucid.wallet().getDelegation();
const tx = await lucid
.newTx()
.withdraw(rewardAddress, delegation.rewards)
.complete();