The transfer function

The transfer() function of the ERC20 standard is used to transfer the tokens from the owner of the token to some other address. As per the standard, the transfer() function must emit the Transfer event on a successful transferal of tokens. The transaction should revert if msg.sender does not have enough tokens to spend. A transfer of a 0 (zero) must also be treated as a valid transfer, and must log the Transfer event. The address that's calling the function must have sufficient tokens to transfer to another address.

The ERC20 standard API is as follows:

function transfer(address to, uint256 value) external returns (bool success);

The transfer() function takes two parameters:

  • to: This is the Ethereum address type to ...

Get Mastering Blockchain Programming with Solidity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.