Efficiently call multiple contracts in a single transaction.
Allows for optional "forwarding" of msg.sender
to the contracts called.
Warning The contracts are being redeployed. Do NOT use yet.
Chain | Multicaller |
---|---|
Ethereum | 0x00000000000066F8295B13Fb252b7f873CBBA71d |
Goerli | 0x00000000000066F8295B13Fb252b7f873CBBA71d |
Polygon | 0x00000000000066F8295B13Fb252b7f873CBBA71d |
Mumbai | 0x00000000000066F8295B13Fb252b7f873CBBA71d |
Optimism | 0x00000000000066F8295B13Fb252b7f873CBBA71d |
Arbitrum | 0x00000000000066F8295B13Fb252b7f873CBBA71d |
Please open an issue if you need help to deploy to an EVM chain of your choice.
src
├─ Multicaller.sol — "The multicaller contract"
└─ MulticallerReader.sol — "Library to read the `msg.sender` of the multicaller contract"
You can use the src/MulticallerReader.sol
library in your contracts to query the Multicaller efficiently.
To install with Foundry:
forge install vectorized/multicaller
To install with Hardhat or Truffle:
npm install multicaller
function aggregate(address[] calldata targets, bytes[] calldata data)
external
payable
returns (bytes[] memory)
Aggregates multiple calls in a single transaction.
The msg.value
will be forwarded to the starting call.
function aggregateWithSender(address[] calldata targets, bytes[] calldata data)
external
payable
returns (bytes[] memory)
Aggregates multiple calls in a single transaction.
The msg.value
will be forwarded to the starting call.
This method will set the multicaller sender to the msg.sender
temporarily for the span of its execution.
This method does not support reentrancy.
fallback() external payable
Returns the address that called aggregateWithSender
on the contract.
The value is always the zero address outside a transaction.
Library to read the msg.sender
of the multicaller contract.
function multicallerSender() internal view returns (address)
Returns the address that called aggregateWithSender
on the multicaller.
function sender() internal view returns (address result)
Returns the address that called aggregateWithSender
on the multicaller, if msg.sender
is the multicaller.
Otherwise, returns msg.sender
.
The contracts are designed with a priority on efficiency and minimalism.
-
Multiple input calldata arrays instead of an array of structs for more compact calldata encoding.
-
Omission of utility functions like
getBlockNumber
for more efficient function dispatch. If you need those functions, just add those functions into your contract, or read them off a separate utility contract like MakerDao's Multicall.
We do not give any warranties and will not be liable for any loss incurred through any use of this codebase.
Multicaller is inspired by and directly modified from:
This project is a public good initiative of sound.xyz and Solady.
We would like to thank our reviewers and contributors for their invaluable help.