TokenManager

The TokenManager subclass provides helper functions for various ERC20 operations that are required during a deposit transaction lifecycle.

Usage: hyphen.tokens

Methods

getSupportedTokens(networkId)

Arguments networkId: number, Chain ID of the network to query.

Returns Promise<SupportedToken[] | void>

type SupportedToken = {
    tokenSymbol: string,
    decimal: number,
    address: string
}

getERC20TokenDecimals(address)

Arguments address: string, Address of the token to query.

Returns Promise<number>, number representing the decimals in the token.

getERC20Allowance(tokenAddress,userAddress,spender)

Arguments tokenAddress: string, Address of the token to query. userAddress: string, Address for which allowance is to be fetched. spender: string, Address of spender

Returns Promise<number>, number representing the allowance.

approveERC20(token,spender,amount,userAddress,infiniteApproval,useBiconomy,wallet?)

Arguments token: string, Address of token.

spender: string, Address of spender.

amount: string, amount to approve.

userAddress: string, address of user for which approval is to be processed.

infiniteApproval: boolean, whether infinite approval is to be processed.

useBiconomy: boolean, whether to use meta-transactions to process approval.

wallet?: ethers.Wallet, optional parameter that can be used to sign transactions offline

Returns Promise<TransactionResponse | undefined>: TransactionResponse of the approval transaction.

Last updated