Deregistration
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.
typescript
import {Cardano} from "@everstake/wallet-sdk-cardano";
import {BlockfrostProvider, MeshWallet} from "@meshsdk/core";
const blockFrostID = '...';
const mnemonic = '...';
const network = 'preview';
const networkID = 0;
const provider = new BlockfrostProvider(blockFrostID);
const paymentWallet = new MeshWallet({
networkId: networkID,
fetcher: provider,
submitter: provider,
key: {
type: 'mnemonic',
words: mnemonic.split(' ')
},
accountType: 'payment'
});
await paymentWallet.init();
const stakeWallet = new MeshWallet({
networkId: networkID,
fetcher: provider,
submitter: provider,
key: {
type: 'mnemonic',
words: mnemonic.split(' ')
},
accountType: 'stake'
});
await stakeWallet.init();
const cardano = new Cardano(network, paymentWallet.addresses.baseAddressBech32!, blockFrostID);
await cardano.init();
const tx = await cardano.deregisterTx();
let signedTx = await paymentWallet.signTx(tx, true);
signedTx = await stakeWallet.signTx(signedTx, true);
const txHash = await paymentWallet.submitTx(signedTx);
console.log('txHash', txHash);