This function can transfer native currencies and tokens that follow the ERC-20 standard. It is recommended to first call the EstimateTransferTokensGas function to get an estimate of the gas fees required for this transaction, which can be displayed to users before the confirm or deny the transaction.
This function should be called after the Login has been invoked.
Calling TransferTokens for an ERC-20 token. For more information on the RegisterToken function, please refer to this page.
import { TransferTokens, RegisterToken,} from'@metafi/metafi-js-package';functionApp() {var customERC20Token =RegisterToken("Custom Token",// name of the token"customToken",// symbol of the tokenchains.matic,// chain of the token"https://d2qdyxy3mxzsfv.cloudfront.net/images/logo/token.png",// icon image for the token"0x2d7882bedcbfddce29ba99965dd3cdf7fcb10a1e",// contract address for the token contract18,// decimals for the token { name:"erc20", } // token standard );consttransferErc20= () => {TransferTokens({ to:"0xd4594dECd0ed8BA4C7d5810dbB8D004C74250BD5", amount:"1", currency: customERC20Token,// use your custom token object herecallback: (result) => {console.log("callback result", result); }, },"YOUR-API-KEY" ); }return ( <div> <buttononClick={transferErc20}>Transfer 1 Matic</button> </div> );}exportdefault App;