Skip to content
On this page

Approve Tokens for Issuance Vault

  • approveToIssuanceVault(sender, tokenAddress, amount): Prepares an approval transaction that will approve the issuance vault to spend a specified amount of a given token on behalf of the sender. This transaction must be executed before depositing tokens.

Parameters

  • sender (string): The address of the transaction sender
  • tokenAddress (string): The address of the ERC20 token to approve (must be supported by issuance vault)
  • amount (BigNumberish): The amount of 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("eth_mainnet", "mmev");

const walletAddress = "0x...";
const usdcAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
const approveAmount = "100.0";

// Create approval transaction
const approveTx = await hysp.approveToIssuanceVault(
  walletAddress,
  usdcAddress,
  approveAmount
);

// Sign and send transaction
const signer = await ethers.getSigner();
const txResponse = await signer.sendTransaction(approveTx);
await txResponse.wait();

Prerequisites

  • Token must be in hysp.supportedIssuanceTokensAddresses
  • Sufficient token balance required
  • Sufficient ETH for gas fees