Skip to content

Instantly share code, notes, and snippets.

@AbhinavXT
Created April 12, 2022 02:56
Show Gist options
  • Save AbhinavXT/1b98587c1fcdc4c08e33255f82157a52 to your computer and use it in GitHub Desktop.
Save AbhinavXT/1b98587c1fcdc4c08e33255f82157a52 to your computer and use it in GitHub Desktop.
//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