Polkadot (DOT): Stake DOT with Kiln Connect
Stake DOT programmatically with Kiln Connect SDK.
Craft dot bonding transaction.
// optional, only for specific setups
const options = {
controllerAccount: '';
rewardDestination: 'Staked';
};
/* async craftBondTx(accountId: string, stashAccount: string, amountDot: number, options?: DotStakeOptions): Promise<DotTransaction> */
const tx = await k.dot.craftBondTx(account.id, WALLET_PUBKEY, 42.2, options);
Craft dot bonding extra token transaction (to be used if you already bonded tokens).
/* async craftBondExtraTx(stashAccount: string, amountDot: number): Promise<DotTransaction> */
const tx = await k.dot.craftBondExtraTx(stashAccount, 2.4);
Craft dot rebond transaction (to be used to rebond unbonding token).
/* async craftRebondTx(controllerAccount: string, amountDot: number): Promise<DotTransaction> */
const tx = await k.dot.craftRebondTx(controllerAccount, 2.4);
Craft dot nominate transaction.
/* async craftNominateTx(controllerAccount: string, validatorAddresses?: string[]): Promise<DotTransaction> */
const tx = await k.dot.craftNominateTx(controllerAccount, validators);
To unstake a position on Polkadot, you need to:
- 1.Unbond the position, which usually takes 28 days.
- 2.Withdraw the Unbonded position.
Craft dot unbonding transaction, there is an unbonding period before your tokens can be withdrawn.
/* async craftUnbondTx(controllerAccount: string, amountDot: number): Promise<DotTransaction> */
const tx = await k.dot.craftUnbondTx(controllerAccount, amountDot);
Craft dot withdraw unbonded token transaction.
/* async craftWithdrawUnbondedTx(controllerAccount: string): Promise<DotTransaction> */
const tx = await k.dot.craftWithdrawUnbondedTx(controllerAccount);
Craft dot chill transaction to chill the controller account associated to the given stash account, meaning that given account will not nominate any validator anymore, so you will stop earning rewards at the beginning of the next era.
/* async craftChillTx(controllerAccount: string): Promise<DotTransaction> */
const tx = await k.dot.craftChillTx(controllerAccount);
Craft dot set controller transaction that updates the controller for the given stash account.
/* async craftSetControllerTx(stashAccount: string, controllerAccount: string): Promise<DotTransaction> */
const tx = await k.dot.craftSetControllerTx(stashAccount, controllerAccount);
Craft dot set reward destination transaction that updates the destination rewards address for the given stash account.
/* async craftSetPayeeTx(controllerAccount: string, rewardsDestination: RewardDestination): Promise<DotTransaction> */
const tx = await k.dot.craftSetPayeeTx(controllerAccount, rewardsDestination);
Sign Polkadot transactions by specifying the integration name and the crafted transaction.
/* async sign(integration: string, transaction: DotTransaction): Promise<SubmittableExtrinsic> */
const signed = await k.dot.sign('vault-1', tx);
Broadcast and get the status of a broadcasted transaction. If you specified a custom RPC url for Polkadot in the SDK configuration, it will be used instead of the default one.
/* async broadcast(transaction: SubmittableExtrinsic): Promise<SubmittedDotTransaction> */
const hash = await k.dot.broadcast(signed);
/* async getTxStatus(transaction: SubmittedDotTransaction): Promise<DotTransactionStatus> */
const status = await k.dot.getTxStatus(signed);