BatchCaller.sol 568 B

1234567891011121314151617181920
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. import {Address} from "../utils/Address.sol";
  4. contract BatchCaller {
  5. struct Call {
  6. address target;
  7. uint256 value;
  8. bytes data;
  9. }
  10. function execute(Call[] calldata calls) external returns (bytes[] memory) {
  11. bytes[] memory returndata = new bytes[](calls.length);
  12. for (uint256 i = 0; i < calls.length; ++i) {
  13. returndata[i] = Address.functionCallWithValue(calls[i].target, calls[i].data, calls[i].value);
  14. }
  15. return returndata;
  16. }
  17. }