Approve ERC20 token on another contract

Hi @abcoathup,

If the Holder is a personal address, is it possible for the Holder to call the approve function of A token on B contract, approving C contract to use the A token?

1 Like

Hello there! I’m not sure I understood what you’re trying to do. Given H (holder) an external account, T an ERC20 token contract, A and B arbitrary smart contracts, which one do you want?:

  1. H to call a function of A that allows B to spend A's token balance
  2. H to call a function of A that allows B to spend H's token balance
  3. H to directly approve B to spend A's token balance by calling T's approval method (no, you can’t)
1 Like
token.approve(recipient, 1e18);

Is only for tokens in contract Holder. (approve to use the tokens already placed in the contract)
When we approve in the contract, for the approve, msg.sender is the contract address.
Was trying to use approve for my wallet in a contract but there is no way to do this, is a security check on ERC20.
The holder of tokens is the one that call approve, we cannot approve the use of tokens for anyone else.
Just a quick note here because I was bashing my head with this in the last days.

2 Likes

Hi @llp0574 & @jboadas,

Welcome to the community :wave:

There is a simple Example on how to use ERC20 token in another contract.

Feel free to ask all the questions that you need.