You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: smart-contracts/advanced/multicall.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ Multicall has the same, precomputed address for all of the networks it is deploy
35
35
36
36
## Usage
37
37
Many libraries and tools such as [ethers-rs](https://docs.rs/ethers/latest/ethers/), [viem](https://viem.sh/), and [ape](https://apeworx.io/) have native Multicall3 integration which can be used in your projects directly. To learn how to use Multicall3 with these tools, check out [Multicall3 examples folder](https://github.com/mds1/multicall/blob/main/examples)
38
+
38
39
### Batching Contract Reads
39
40
Batching contract reads, one of the most common use cases, allows a single `eth_call` JSON RPC request to return the results of multiple contract function calls. It has many benefits:
40
41
@@ -120,15 +121,13 @@ Whenever a CALL is executed, the _context_ changes.
120
121
New context means storage operations will be performed on the called contract, there is a new value (i.e. `msg.value`), and a new caller (i.e. `msg.sender`).
121
122
122
123
The FVM also supports the [`DELEGATECALL`](https://www.evm.codes/#f4) opcode, which is similar to `CALL`, but different in a very important way: it _does not_ change the context of the call.
123
-
This means the contract being delegatecalled will see the same `msg.sender`, the same `msg.value`, and operate on the same storage as the calling contract. This is very powerful, but can also be dangerous.
124
-
125
-
It's important to note that you cannot delegatecall from an EOA—an EOA can only call a contract, not delegatecall it.
124
+
This means the contract being delegatecalled will see the same `msg.sender`, the same `msg.value`, and operate on the same storage as the calling contract.
126
125
127
-
Now that we understand the difference between `CALL` and `DELEGATECALL`, let's see how this applies to `msg.sender` and `msg.value` concerns.
128
-
We know that we can either `CALL` or `DELEGATECALL` to a contract, and that `msg.sender` will be different depending on which opcode we use.
126
+
It's important to note that you cannot delegatecall from an EOA — an EOA can only call a contract, not delegatecall it.
129
127
130
128
Because you cannot delegatecall from an EOA, this significantly reduces the benefit of calling Multicall3 from an EOA—any calls the Multicall3 executes will have the MultiCall3 address as the `msg.sender`.
131
-
**This means you should only call Multicall3 from an EOA if the `msg.sender` does not matter.**
129
+
130
+
**This means you should only call Multicall3 from an EOA if the `msg.sender` does not matter.**`msg.sender` will be different depending on which opcode you use.
132
131
133
132
If you are using a contract wallet or executing a call to Multicall3 from another contract, you can either CALL or DELEGATECALL.
134
133
Calls will behave the same as described above for the EOA case, and delegatecalls will preserve the context.
0 commit comments