IERC20.sol 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
  3. pragma solidity ^0.8.0;
  4. /**
  5. * @dev Interface of the ERC20 standard as defined in the EIP.
  6. */
  7. interface IERC20 {
  8. /**
  9. * @dev Emitted when `value` tokens are moved from one account (`from`) to
  10. * another (`to`).
  11. *
  12. * Note that `value` may be zero.
  13. */
  14. event Transfer(address indexed from, address indexed to, uint256 value);
  15. /**
  16. * @dev Emitted when the allowance of a `spender` for an `owner` is set by
  17. * a call to {approve}. `value` is the new allowance.
  18. */
  19. event Approval(address indexed owner, address indexed spender, uint256 value);
  20. /**
  21. * @dev Returns the amount of tokens in existence.
  22. */
  23. function totalSupply() external view returns (uint256);
  24. /**
  25. * @dev Returns the amount of tokens owned by `account`.
  26. */
  27. function balanceOf(address account) external view returns (uint256);
  28. /**
  29. * @dev Moves `amount` tokens from the caller's account to `to`.
  30. *
  31. * Returns a boolean value indicating whether the operation succeeded.
  32. *
  33. * Emits a {Transfer} event.
  34. */
  35. function transfer(address to, uint256 amount) external returns (bool);
  36. /**
  37. * @dev Returns the remaining number of tokens that `spender` will be
  38. * allowed to spend on behalf of `owner` through {transferFrom}. This is
  39. * zero by default.
  40. *
  41. * This value changes when {approve} or {transferFrom} are called.
  42. */
  43. function allowance(address owner, address spender) external view returns (uint256);
  44. /**
  45. * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
  46. *
  47. * Returns a boolean value indicating whether the operation succeeded.
  48. *
  49. * IMPORTANT: Beware that changing an allowance with this method brings the risk
  50. * that someone may use both the old and the new allowance by unfortunate
  51. * transaction ordering. One possible solution to mitigate this race
  52. * condition is to first reduce the spender's allowance to 0 and set the
  53. * desired value afterwards:
  54. * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  55. *
  56. * Emits an {Approval} event.
  57. */
  58. function approve(address spender, uint256 amount) external returns (bool);
  59. /**
  60. * @dev Moves `amount` tokens from `from` to `to` using the
  61. * allowance mechanism. `amount` is then deducted from the caller's
  62. * allowance.
  63. *
  64. * Returns a boolean value indicating whether the operation succeeded.
  65. *
  66. * Emits a {Transfer} event.
  67. */
  68. function transferFrom(address from, address to, uint256 amount) external returns (bool);
  69. }