Solidity Multicall – Implementing Multicall with transferFrom

multicallsoliditytransferfrom

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

Best Answer

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.

Related Topic