approveEth()

Initiates transaction to approve contract spend tokens

Method Parameters

tokenBridgeAddress: string

Ethereum bridge contract address

tokenAddress: string

Ethereum token address

signer: ethers.Signer

ethers js Signer

amount: ethers.BigNumberish

Amount to approve for spend (ethers js BigNumberish)

Returns

Returns ethers js ethers.ContractReceipt

Usage

import { ethers } from "ethers";
import { approveEth, getAllowanceEth} from "@algo-foundry/messina-sdk";

const provider = new ethers.providers.WebSocketProvider(<ETH_NODE_URL>) as any;   
const signer = new ethers.Wallet(<ETH_PRIVATE_KEY>, provider);

const allowance: ethers.BigNumber = await getAllowanceEth("0xf72a04B891bA46819D83c75687d31f22f6d646c1","0xbF0482884043B7ea1eB55516770C217C77CC7A48", signer);

if(allowance.lt(AMOUNT_TO_TRANSFER)){
  await approveEth(
    "0xf72a04B891bA46819D83c75687d31f22f6d646c1",
    "0xbF0482884043B7ea1eB55516770C217C77CC7A48",
    signer,
    AMOUNT_TO_TRANSFER
  );
}

Last updated