0

I want contract2 to be able to transfer the tokens from contract1.

So i set allowance to -1

If i understand correctly it's not "infinite", but it's the highest possible number in EVM.

My question is... Do i need to create a function inside the contract that will reset the allowance back to -1? As users interact with the contract, could they drain the allowance to 0 and render the contract useless?

1 Answer 1

0

Not really, except if the token contract has a malicious approve() function that allows for an adversary to set approval arbitrarily, I don't see how that's an issue, as _allowance is always checked against _msgSender(), which is the signer that called the token contract.

1
  • User deposits tokens into Contract1. And Contract2 transfers the tokens from Contract1 to itself. User must give allowance to Contract1, but Contract2 then takes those tokens, so when launching Contract1, i set allowance to -1 for Contract2. The question is now... Do i need to add a function that will "reset" allowance to -1 again?
    – smenir443
    Commented Oct 9, 2021 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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