The transferFrom function

The transferFrom() function transfers the tokens from an owner's account to the receiver account, but only if the transaction initiator has sufficient allowance that has been previously approved by the owner to the transaction initiator. To transfer the tokens using the transferFrom() function, approver must have called the approve() function prior. As per the standard, the transferFrom() function must fire the Transfer event upon the successful execution and transfer of tokens. The transfer of 0 (zero) value must also be treated as a valid transfer and should fire the Transfer event.

The ERC20 standard API is as follows:

function transferFrom(address from, address to, uint256 value) external returns (bool success ...

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.