Multicall.sol 796 B

12345678910111213141516171819202122232425
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.0.0-rc.0) (utils/Multicall.sol)
  3. pragma solidity ^0.8.20;
  4. import {Address} from "./Address.sol";
  5. /**
  6. * @dev Provides a function to batch together multiple calls in a single external call.
  7. *
  8. * @custom:stateless
  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. }