1

I have an ERC20 test contract, also I did multicall with delegatecall function instead of call. I have a three accounts: account1, account2, and account3. account1 can spend tokens from account2 (I did transaction here, and this is works)

Then I tried to send the same transaction with multicall contract, and I got an error: ERC20: insufficient allowance, here a callstack

So I see in both transactions allowance call, but in the second transaction I see allowance as 0. How to fix that? and why that happened?

2

1 Answer 1

0

Delegatecall requires target and source to have compatible storage layouts. You'll be executing the target's bytecode in the source contract's storage. If the Multicall contracts delegatecalls to the ERC20 it will not work as you are expecting

  1. they don't have compatible layouts,
  2. it will be modifying the Multicall storage and not the ERC20 storage.

Check the answer for the Difference between CALL, CALLCODE and DELEGATECALL to understand the details.

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.