August 2019
Intermediate to advanced
486 pages
13h 52m
English
If you are calling the transferFrom() function from within a Solidity contract, it is recommended to enclose the call with require() to ensure that the token transfer executed successfully and, in case of any transfer failure, the transaction should revert. It is defined as follows:
require(ERC20.transferFrom(from, to, value));
As we have seen, for the transferFrom() function to work, the approve() function must be called to approve the allowances. It's the same with the Solidity contract. If you have the preceding statement in your Solidity contract, the address of which, let's say, is 0xContractAddress, the user must have called the approve(0xContractAddress, amountOfTokens) function for the contract address ...