1

so I have an account 0x1, and account 0x2. both of them have 0xToken. I want to send tokens to 0x3 with multicall transaction. I give allowance from 0x2 to 0x2 => 0x1 able to spend tokens from 0x2. Then I tried to make multicall transaction:

TransferFrom(0x1, 0xReceiver, 100)
TransferFrom(0x2, 0xReceiver, 100)

but as a result of transaction I got ERC20: insufficient allowance

But if I add allowance to 0xMcall Address, then it works fine, but in this case I have an security issue, because anybody can make transaction and spent my tokens from my addresses. How to correctly make multicall transferFrom in this case? as an example of transaction https://dashboard.tenderly.co/asd123444/project/tx/sepolia/0x180e0bfe794ca9be49506bb95cf6bb770a368fa2ff8611a943442cad4c2c4a57

0x9b841f5eb54995f9f206ab6511b48aac9f6fcec5 is https://github.com/mds1/multicall

1 Answer 1

0

Short answer: you can't, or at least you can't securely if using an EOA directly. To do something similar, you'd have to create your own contract, grant that one owner-only protection, grant allowance to it, and call the Multicall3 contract from within yours, setting the allowance again but immediately calling the multicall so that the allowance gets spent and back to zero after finishing the transaction.

4
  • if I will change contract as ``` if msg.sender == 0x1 or another my address ``` will it work?
    – anguser
    Mar 28 at 18:46
  • No idea, you didn't mention you were using a contract to perform this operation. I'd have to take a look at the code. Mar 29 at 0:24
  • I mean such contract with caller limitation paste.ee/p/ar8ka#s=0&l=46
    – anguser
    Mar 29 at 9:56
  • Oh yes, you could redeploy that contract and add an onlyOwner modified so that only you can invoke the function. That'd be perfectly safe. Mar 29 at 11:01

Your Answer

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

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