Staking your wallet

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();

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();
💡

Register and Delegate to a stake pool You can combine both registration and delegation into a single transaction

const tx = await lucid
  .newTx()
  .registerAndDelegateToPool(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();

Deregister stake key

Deregistering a stake key will reclaim the 2 ADA deposit initially taken during registration.

const tx = await lucid
  .newTx()
  .deRegisterStake(rewardAddress)
  .complete();

💡

You can query the reward address (stake_...) associated with your stake key:

const rewardAddress = await lucid.wallet().rewardAddress();