draft-IERC20Permit.sol 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.0-rc.0 (token/ERC20/extensions/draft-IERC20Permit.sol)
  3. pragma solidity ^0.8.0;
  4. /**
  5. * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
  6. * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
  7. *
  8. * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
  9. * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
  10. * need to send a transaction, and thus is not required to hold Ether at all.
  11. */
  12. interface IERC20Permit {
  13. /**
  14. * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
  15. * given ``owner``'s signed approval.
  16. *
  17. * IMPORTANT: The same issues {IERC20-approve} has related to transaction
  18. * ordering also apply here.
  19. *
  20. * Emits an {Approval} event.
  21. *
  22. * Requirements:
  23. *
  24. * - `spender` cannot be the zero address.
  25. * - `deadline` must be a timestamp in the future.
  26. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
  27. * over the EIP712-formatted function arguments.
  28. * - the signature must use ``owner``'s current nonce (see {nonces}).
  29. *
  30. * For more information on the signature format, see the
  31. * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
  32. * section].
  33. */
  34. function permit(
  35. address owner,
  36. address spender,
  37. uint256 value,
  38. uint256 deadline,
  39. uint8 v,
  40. bytes32 r,
  41. bytes32 s
  42. ) external;
  43. /**
  44. * @dev Returns the current nonce for `owner`. This value must be
  45. * included whenever a signature is generated for {permit}.
  46. *
  47. * Every successful call to {permit} increases ``owner``'s nonce by one. This
  48. * prevents a signature from being used multiple times.
  49. */
  50. function nonces(address owner) external view returns (uint256);
  51. /**
  52. * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
  53. */
  54. // solhint-disable-next-line func-name-mixedcase
  55. function DOMAIN_SEPARATOR() external view returns (bytes32);
  56. }