Created
April 12, 2022 02:56
-
-
Save AbhinavXT/1b98587c1fcdc4c08e33255f82157a52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.10; | |
import "hardhat/console.sol"; | |
contract Batch { | |
function multiCall(address[] calldata targets, bytes[] calldata data) | |
public | |
returns (bytes[] memory) | |
{ | |
require(targets.length == data.length, "target length != data length"); | |
bytes[] memory results = new bytes[](data.length); | |
for (uint256 i; i < targets.length; i++) { | |
(bool success, bytes memory result) = targets[i].call(data[i]); | |
require(success, "call failed"); | |
results[i] = result; | |
} | |
return results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment