🎴Transfer Tokens
Transfer ERC20 tokens on any blockchain - ETH (Ethereum), BNB (Binance Smart Chain), MATIC (Polygon)
Transfer ERC20 Tokens
To transfer ERC20 tokens, follow the steps:
Construct an
options
object and settype:"erc20"
amount: Moralis.Units.Token("0.5", "18") //Converts to
wei
receiver: "0x000..." //wallet address
contractAddress: "0x..." //contract of the ERC20 token
Call the Moralis transfer function as shown below
By using Moralis.Units.Token
helper function you can multiply the amount you want to send by the number of decimals. This is required to construct an ERC20 transaction.
The contract address and the number of decimals for a token can normally be found on Etherscan or on the website of the project.
Get the address and decimals programmatically of a token by using Moralis SDK Moralis.Web3API.token.getTokenMetadataBySymbol().
Resolving the results
Moralis.transfer()
returns a transaction response after it is executed. The below page shows how to consume the data returned.
Last updated