0

I know transferring ERC-20 token from my wallet to a custom contract. The smart contract has to call transferFrom() to enable withdraw.

ERC20 token = ERC20(_tokenAddress);
token.transferFrom(msg.sender, this, _amount);

But I need to first call approve function on the token contract to approve this contract to withraw funds on my behalf. I want to know is there any way to call the token.approve() method from this contract itself?

0

token.approve() has to be called by the account that owns the tokens (you), so no, you can't call it from some other account (including a contract).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.