Skip to content
On this page

Register and Delegate

The registerAndDelegateCborHexTx method creates unsigned transaction for register stake account and delegate to staking pool.

typescript
import {CardanoWeb3} from "cardano-web3-js"
import {Cardano} from "@everstake/wallet-sdk-cardano";

const web3 = new CardanoWeb3({network: "preview"});
const mnemonic = '...';
const account = web3.account.fromMnemonic(mnemonic);
const blockForstProjectID = '...';

const cardano = new Cardano('preview', account.__config.paymentAddress, blockForstProjectID);
const registerAndDelegation = await cardano.registerAndDelegateCborHexTx();
const state = await account.getState();
const hash = await web3.importTx(registerAndDelegation).signWithAccount(account, state.utxos).applyAndSubmit();
console.log('tx hash', hash);

Also, an alternative option it can be called as two separate methods.

typescript
const registerAndDelegation = await cardano.registerAndDelegateCborHexTx();
typescript
const deregistrationTx = await cardano.deregisterCborHexTx();