draft-IERC6909.sol 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. import {IERC165} from "../utils/introspection/IERC165.sol";
  4. /**
  5. * @dev Required interface of an ERC-6909 compliant contract, as defined in the
  6. * https://eips.ethereum.org/EIPS/eip-6909[ERC].
  7. */
  8. interface IERC6909 is IERC165 {
  9. /**
  10. * @dev Emitted when the allowance of a `spender` for an `owner` is set for a token of type `id`.
  11. * The new allowance is `amount`.
  12. */
  13. event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
  14. /**
  15. * @dev Emitted when `owner` grants or revokes operator status for a `spender`.
  16. */
  17. event OperatorSet(address indexed owner, address indexed spender, bool approved);
  18. /**
  19. * @dev Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` initiated by `caller`.
  20. */
  21. event Transfer(
  22. address caller,
  23. address indexed sender,
  24. address indexed receiver,
  25. uint256 indexed id,
  26. uint256 amount
  27. );
  28. /**
  29. * @dev Returns the amount of tokens of type `id` owned by `owner`.
  30. */
  31. function balanceOf(address owner, uint256 id) external view returns (uint256);
  32. /**
  33. * @dev Returns the amount of tokens of type `id` that `spender` is allowed to spend on behalf of `owner`.
  34. *
  35. * NOTE: Does not include operator allowances.
  36. */
  37. function allowance(address owner, address spender, uint256 id) external view returns (uint256);
  38. /**
  39. * @dev Returns true if `spender` is set as an operator for `owner`.
  40. */
  41. function isOperator(address owner, address spender) external view returns (bool);
  42. /**
  43. * @dev Sets an approval to `spender` for `amount` tokens of type `id` from the caller's tokens.
  44. *
  45. * Must return true.
  46. */
  47. function approve(address spender, uint256 id, uint256 amount) external returns (bool);
  48. /**
  49. * @dev Grants or revokes unlimited transfer permission of any token id to `spender` for the caller's tokens.
  50. *
  51. * Must return true.
  52. */
  53. function setOperator(address spender, bool approved) external returns (bool);
  54. /**
  55. * @dev Transfers `amount` of token type `id` from the caller's account to `receiver`.
  56. *
  57. * Must return true.
  58. */
  59. function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
  60. /**
  61. * @dev Transfers `amount` of token type `id` from `sender` to `receiver`.
  62. *
  63. * Must return true.
  64. */
  65. function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
  66. }
  67. /**
  68. * @dev Optional extension of {IERC6909} that adds metadata functions.
  69. */
  70. interface IERC6909Metadata is IERC6909 {
  71. /**
  72. * @dev Returns the name of the token of type `id`.
  73. */
  74. function name(uint256 id) external view returns (string memory);
  75. /**
  76. * @dev Returns the ticker symbol of the token of type `id`.
  77. */
  78. function symbol(uint256 id) external view returns (string memory);
  79. /**
  80. * @dev Returns the number of decimals for the token of type `id`.
  81. */
  82. function decimals(uint256 id) external view returns (uint8);
  83. }
  84. /**
  85. * @dev Optional extension of {IERC6909} that adds content URI functions.
  86. */
  87. interface IERC6909ContentURI is IERC6909 {
  88. /**
  89. * @dev Returns URI for the contract.
  90. */
  91. function contractURI() external view returns (string memory);
  92. /**
  93. * @dev Returns the URI for the token of type `id`.
  94. */
  95. function tokenURI(uint256 id) external view returns (string memory);
  96. }
  97. /**
  98. * @dev Optional extension of {IERC6909} that adds a token supply function.
  99. */
  100. interface IERC6909TokenSupply is IERC6909 {
  101. /**
  102. * @dev Returns the total supply of the token of type `id`.
  103. */
  104. function totalSupply(uint256 id) external view returns (uint256);
  105. }