Token

Token Actions

Transactional Functions

Transfer Token Contract

TransferToken.sol contract is used for executing the transfer of a designated asset to a specified payable recipient, ensuring a targeted and secure movement of tokens.

function transferToken(address token, address payable to, address from, uint256 amount)

Process

  • Validation: The function first validates the addresses and amounts using the validateAddress and validateUint methods from the Security library. It checks that the to_, from_, and token_ addresses are valid and the amount_ is a non-zero positive integer.

  • ERC20 Token Transfer: The function handles the transfer of ERC20 tokens. It creates an instance of the ERC20 token using the token_ address and then calls the transferFrom method of the ERC20 token to transfer amount_ tokens from the from_ address to the to_ address.

  • Transfer Verification: The function checks if the token transfer was successful. If not, it reverts with an error message "ERR: Token transfer failed".

Last updated