I need to send an ERC20 Token from a contract to another contract and calling a function of the other contract at the same time.
I know how to transfer an ERC20 Token from solidity to another contract, but how do I call a payable function of the recipient contract at the same time, to use the ERC20 Token I just sent?
Best Answer
In ERC20, you need to first
approve
the token for the contract providing the service.Then you can use
transferFrom
function of ERC20 Token within your service contract to use the approved amount of tokens.This explains it in more detail - https://medium.com/coinmonks/ethereum-payable-token-and-how-it-works-3bf3349a6a77