Approve Tokens for Redemption Vault
approveToRedemptionVault(sender, amount): Prepares an approval transaction that will approve the redemption vault to spend a specified amount of the collateral token on behalf of the sender. This transaction must be executed before redeeming tokens.
Parameters
sender(string): The address of the transaction senderamount(BigNumberish): The amount of collateral tokens to approve
Code Example
ts
import { HYSP } from "@everstake/wallet-sdk-hysp";
import { ethers } from "ethers";
// Initialize SDK
const hysp = new HYSP();
await hysp.init();
const walletAddress = "0x...";
const redeemAmount = "50.0";
// Create approval transaction
const approveTx = await hysp.approveToRedemptionVault(
walletAddress,
redeemAmount
);
// Sign and send transaction
const signer = await ethers.getSigner();
const txResponse = await signer.sendTransaction(approveTx);
await txResponse.wait();
Prerequisites
- Sufficient collateral token balance required
- Sufficient ETH for gas fees