Multicall.sol 781 B

12345678910111213141516171819202122232425
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)
  3. pragma solidity ^0.8.0;
  4. import "./Address.sol";
  5. /**
  6. * @dev Provides a function to batch together multiple calls in a single external call.
  7. *
  8. * _Available since v4.1._
  9. */
  10. abstract contract Multicall {
  11. /**
  12. * @dev Receives and executes a batch of function calls on this contract.
  13. * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
  14. */
  15. function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
  16. results = new bytes[](data.length);
  17. for (uint256 i = 0; i < data.length; i++) {
  18. results[i] = Address.functionDelegateCall(address(this), data[i]);
  19. }
  20. return results;
  21. }
  22. }