[Ethereum] Help on transferFrom and Approve functions

address.transfererc-20soliditytokens

We have a token contract A and an Escrow contract B. While transferring token from an address to contract B we are using transferFrom function which overridden from contract A. But in need to do the transfer , we have to call approve function on contract A. This works if we call the approve function directly from contract A. But if we are overriding the approve function just like transferFrom on contract B, it is failing. Could someone please explain how we can call approve from contract B itself.

Best Answer

If you want to approve tokens in the contract b to be moved by someone else, this will work. But if you want to approve tokens of user X to be moved by user Y from contract B this won't work. The issue is that calling approve from contract B will have as msg.sender and it will fail.

Hope this helps

Related Topic