IERC1363.sol 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
  3. pragma solidity >=0.6.2;
  4. import {IERC20} from "./IERC20.sol";
  5. import {IERC165} from "./IERC165.sol";
  6. /**
  7. * @title IERC1363
  8. * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
  9. *
  10. * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
  11. * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
  12. */
  13. interface IERC1363 is IERC20, IERC165 {
  14. /*
  15. * Note: the ERC-165 identifier for this interface is 0xb0202a11.
  16. * 0xb0202a11 ===
  17. * bytes4(keccak256('transferAndCall(address,uint256)')) ^
  18. * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
  19. * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
  20. * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
  21. * bytes4(keccak256('approveAndCall(address,uint256)')) ^
  22. * bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
  23. */
  24. /**
  25. * @dev Moves a `value` amount of tokens from the caller's account to `to`
  26. * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
  27. * @param to The address which you want to transfer to.
  28. * @param value The amount of tokens to be transferred.
  29. * @return A boolean value indicating whether the operation succeeded unless throwing.
  30. */
  31. function transferAndCall(address to, uint256 value) external returns (bool);
  32. /**
  33. * @dev Moves a `value` amount of tokens from the caller's account to `to`
  34. * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
  35. * @param to The address which you want to transfer to.
  36. * @param value The amount of tokens to be transferred.
  37. * @param data Additional data with no specified format, sent in call to `to`.
  38. * @return A boolean value indicating whether the operation succeeded unless throwing.
  39. */
  40. function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
  41. /**
  42. * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
  43. * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
  44. * @param from The address which you want to send tokens from.
  45. * @param to The address which you want to transfer to.
  46. * @param value The amount of tokens to be transferred.
  47. * @return A boolean value indicating whether the operation succeeded unless throwing.
  48. */
  49. function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
  50. /**
  51. * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
  52. * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
  53. * @param from The address which you want to send tokens from.
  54. * @param to The address which you want to transfer to.
  55. * @param value The amount of tokens to be transferred.
  56. * @param data Additional data with no specified format, sent in call to `to`.
  57. * @return A boolean value indicating whether the operation succeeded unless throwing.
  58. */
  59. function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
  60. /**
  61. * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
  62. * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
  63. * @param spender The address which will spend the funds.
  64. * @param value The amount of tokens to be spent.
  65. * @return A boolean value indicating whether the operation succeeded unless throwing.
  66. */
  67. function approveAndCall(address spender, uint256 value) external returns (bool);
  68. /**
  69. * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
  70. * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
  71. * @param spender The address which will spend the funds.
  72. * @param value The amount of tokens to be spent.
  73. * @param data Additional data with no specified format, sent in call to `spender`.
  74. * @return A boolean value indicating whether the operation succeeded unless throwing.
  75. */
  76. function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
  77. }