-
Notifications
You must be signed in to change notification settings - Fork 215
delegatecall #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What is the use case for 1? For 2, that is tracked in #146 |
1.1 For some contracts, they perform checks on the caller (msg.sender), such as supporting only whitelisted callers. In such cases, using call may result in incorrect readings, while using delegatecall can return the correct result. 1.2 For certain write methods, such as withdraw, they directly transfer funds to msg.sender. Using multicall will correctly transfer the amount to msg.sender, but using call will withdraw the amount to the multicall contract itself. e.g: https://bscscan.com/tx/0x924970e981b924806c65b4e176d71c2f8f65e44cc62dec5ff1357b340eff70d7#eventlog |
For those use cases, you want to delegatecall to the Multicall contract. This way your contract (say, a Safe wallet) executes some arbitrary sequence of calls and is the msg.sender during e.g. the whitelist check. If the Multicall contract did the delegatecall, that means the whitelist check now enforces who can call the Multicall contract, because the whitelist code is executing in the context of Multicall |
for example:
If called Wallet directly like this, transfer msg.sender should be userAddress
If called Wallet by delegate call like this, according to the DELEGATE_CALL by EIP-7 design, the transfer msg.sender should still be a userAddress, right?
|
In your second example, where your EOA calls the multicall contract, and the multicall contract delegatecalls the wallet, then when I would suggest reading the solidity docs or some tutorials like the ones by @PatrickAlphaC to learn more about delegatecall and how it's typically used :) |
Hi, I just saw this. I think there are use cases where a delegate call would help. For instance, Let's say I want to aggregate interaction with multiple DeFi protocols from a ERC-4337 smart account, and some of these calls are made through adapter/helper contracts.
It isn't possible right now. A solution may be having an |
Sorry @marcelomorgado I don't understand. If you want to aggregate interaction from a 4337 smart account, you can already do that with batch calls. For example: https://github.com/eth-infinitism/account-abstraction/blob/f1c5c11b273b7ddae26bb20809419b33ccb8f043/contracts/samples/SimpleAccount.sol#L63-L82 Or if the wallet doesn't have native batching but does have delegatecall (like gnosis safe), you delegatecall from your wallet to the Multicall3 contract to execute batch calls. |
Hi @mds1 let's say I want to have such call:
Since Multcall3 doesn't support batching delegate calls it isn't currently possible. |
Revise the point in requirement 2. I think the method name should not be called
We also deployed some contract for us before And found some deployed contract: eth: 0xe9bbcd277e2c029c8b5f3c744dad93c290ad01a9 File 9 of 27 : AddressUpgradeable.sol L40 |
It seems https://github.com/jaydenwindle/multicall-authenticated and ERC-2771 is the solution for point 1. |
delegatecall
,isContract
to determine if an address is a contract by checking if the code size is greater than 0?The text was updated successfully, but these errors were encountered: