Add Multicall module (#2608)
This commit is contained in:
21
contracts/utils/Multicall.sol
Normal file
21
contracts/utils/Multicall.sol
Normal file
@ -0,0 +1,21 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "./Address.sol";
|
||||
|
||||
/**
|
||||
* @dev Provides a function to batch together multiple calls in a single external call.
|
||||
*/
|
||||
abstract contract Multicall {
|
||||
/**
|
||||
* @dev Receives and executes a batch of function calls on this contract.
|
||||
*/
|
||||
function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
|
||||
results = new bytes[](data.length);
|
||||
for (uint i = 0; i < data.length; i++) {
|
||||
results[i] = Address.functionDelegateCall(address(this), data[i]);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/
|
||||
Miscellaneous contracts and libraries containing utility functions you can use to improve security, work with new data types, or safely use low-level primitives.
|
||||
|
||||
The {Address}, {Arrays} and {Strings} libraries provide more operations related to these native data types, while {SafeCast} adds ways to safely convert between the different signed and unsigned numeric types.
|
||||
{Multicall} provides a function to batch together multiple calls in a single external call.
|
||||
|
||||
For new data types:
|
||||
|
||||
@ -94,3 +95,5 @@ Note that, in all cases, accounts simply _declare_ their interfaces, but they ar
|
||||
{{Counters}}
|
||||
|
||||
{{Strings}}
|
||||
|
||||
{{Multicall}}
|
||||
|
||||
Reference in New Issue
Block a user