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