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