IERC1363Receiver.sol 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363Receiver.sol)
  3. pragma solidity ^0.8.20;
  4. /**
  5. * @title IERC1363Receiver
  6. * @dev Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall`
  7. * from ERC-1363 token contracts.
  8. */
  9. interface IERC1363Receiver {
  10. /**
  11. * @dev Whenever ERC-1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall`
  12. * by `operator` from `from`, this function is called.
  13. *
  14. * NOTE: To accept the transfer, this must return
  15. * `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
  16. * (i.e. 0x88a7ca5c, or its own function selector).
  17. *
  18. * @param operator The address which called `transferAndCall` or `transferFromAndCall` function.
  19. * @param from The address which the tokens are transferred from.
  20. * @param value The amount of tokens transferred.
  21. * @param data Additional data with no specified format.
  22. * @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` if transfer is allowed unless throwing.
  23. */
  24. function onTransferReceived(
  25. address operator,
  26. address from,
  27. uint256 value,
  28. bytes calldata data
  29. ) external returns (bytes4);
  30. }