draft-IERC20Permit.sol 2.1 KB

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