poseidon-solidity-example/lib/forge-std/src/interfaces/IERC721.sol
lib/forge-std/src/interfaces/IERC721.solRaw
1// SPDX-License-Identifier: MIT
2pragma solidity >=0.6.2;
3
4import "./IERC165.sol";
5
6/// @title ERC-721 Non-Fungible Token Standard
7/// @dev See https://eips.ethereum.org/EIPS/eip-721
8/// Note: the ERC-165 identifier for this interface is 0x80ac58cd.
9interface IERC721 is IERC165 {
10 /// @dev This emits when ownership of any NFT changes by any mechanism.
11 /// This event emits when NFTs are created (`from` == 0) and destroyed
12 /// (`to` == 0). Exception: during contract creation, any number of NFTs
13 /// may be created and assigned without emitting Transfer. At the time of
14 /// any transfer, the approved address for that NFT (if any) is reset to none.
15 event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
16
17 /// @dev This emits when the approved address for an NFT is changed or
18 /// reaffirmed. The zero address indicates there is no approved address.
19 /// When a Transfer event emits, this also indicates that the approved
20 /// address for that NFT (if any) is reset to none.
21 event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
22
23 /// @dev This emits when an operator is enabled or disabled for an owner.
24 /// The operator can manage all NFTs of the owner.
25 event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
26
27 /// @notice Count all NFTs assigned to an owner
28 /// @dev NFTs assigned to the zero address are considered invalid, and this
29 /// function throws for queries about the zero address.
30 /// @param _owner An address for whom to query the balance
31 /// @return The number of NFTs owned by `_owner`, possibly zero
32 function balanceOf(address _owner) external view returns (uint256);
33
34 /// @notice Find the owner of an NFT
35 /// @dev NFTs assigned to zero address are considered invalid, and queries
36 /// about them do throw.
37 /// @param _tokenId The identifier for an NFT
38 /// @return The address of the owner of the NFT
39 function ownerOf(uint256 _tokenId) external view returns (address);
40
41 /// @notice Transfers the ownership of an NFT from one address to another address
42 /// @dev Throws unless `msg.sender` is the current owner, an authorized
43 /// operator, or the approved address for this NFT. Throws if `_from` is
44 /// not the current owner. Throws if `_to` is the zero address. Throws if
45 /// `_tokenId` is not a valid NFT. When transfer is complete, this function
46 /// checks if `_to` is a smart contract (code size > 0). If so, it calls
47 /// `onERC721Received` on `_to` and throws if the return value is not
48 /// `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
49 /// @param _from The current owner of the NFT
50 /// @param _to The new owner
51 /// @param _tokenId The NFT to transfer
52 /// @param data Additional data with no specified format, sent in call to `_to`
53 function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external payable;
54
55 /// @notice Transfers the ownership of an NFT from one address to another address
56 /// @dev This works identically to the other function with an extra data parameter,
57 /// except this function just sets data to "".
58 /// @param _from The current owner of the NFT
59 /// @param _to The new owner
60 /// @param _tokenId The NFT to transfer
61 function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
62
63 /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
64 /// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
65 /// THEY MAY BE PERMANENTLY LOST
66 /// @dev Throws unless `msg.sender` is the current owner, an authorized
67 /// operator, or the approved address for this NFT. Throws if `_from` is
68 /// not the current owner. Throws if `_to` is the zero address. Throws if
69 /// `_tokenId` is not a valid NFT.
70 /// @param _from The current owner of the NFT
71 /// @param _to The new owner
72 /// @param _tokenId The NFT to transfer
73 function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
74
75 /// @notice Change or reaffirm the approved address for an NFT
76 /// @dev The zero address indicates there is no approved address.
77 /// Throws unless `msg.sender` is the current NFT owner, or an authorized
78 /// operator of the current owner.
79 /// @param _approved The new approved NFT controller
80 /// @param _tokenId The NFT to approve
81 function approve(address _approved, uint256 _tokenId) external payable;
82
83 /// @notice Enable or disable approval for a third party ("operator") to manage
84 /// all of `msg.sender`'s assets
85 /// @dev Emits the ApprovalForAll event. The contract MUST allow
86 /// multiple operators per owner.
87 /// @param _operator Address to add to the set of authorized operators
88 /// @param _approved True if the operator is approved, false to revoke approval
89 function setApprovalForAll(address _operator, bool _approved) external;
90
91 /// @notice Get the approved address for a single NFT
92 /// @dev Throws if `_tokenId` is not a valid NFT.
93 /// @param _tokenId The NFT to find the approved address for
94 /// @return The approved address for this NFT, or the zero address if there is none
95 function getApproved(uint256 _tokenId) external view returns (address);
96
97 /// @notice Query if an address is an authorized operator for another address
98 /// @param _owner The address that owns the NFTs
99 /// @param _operator The address that acts on behalf of the owner
100 /// @return True if `_operator` is an approved operator for `_owner`, false otherwise
101 function isApprovedForAll(address _owner, address _operator) external view returns (bool);
102}
103
104/// @dev Note: the ERC-165 identifier for this interface is 0x150b7a02.
105interface IERC721TokenReceiver {
106 /// @notice Handle the receipt of an NFT
107 /// @dev The ERC721 smart contract calls this function on the recipient
108 /// after a `transfer`. This function MAY throw to revert and reject the
109 /// transfer. Return of other than the magic value MUST result in the
110 /// transaction being reverted.
111 /// Note: the contract address is always the message sender.
112 /// @param _operator The address which called `safeTransferFrom` function
113 /// @param _from The address which previously owned the token
114 /// @param _tokenId The NFT identifier which is being transferred
115 /// @param _data Additional data with no specified format
116 /// @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
117 /// unless throwing
118 function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data)
119 external
120 returns (bytes4);
121}
122
123/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
124/// @dev See https://eips.ethereum.org/EIPS/eip-721
125/// Note: the ERC-165 identifier for this interface is 0x5b5e139f.
126interface IERC721Metadata is IERC721 {
127 /// @notice A descriptive name for a collection of NFTs in this contract
128 function name() external view returns (string memory _name);
129
130 /// @notice An abbreviated name for NFTs in this contract
131 function symbol() external view returns (string memory _symbol);
132
133 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
134 /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
135 /// 3986. The URI may point to a JSON file that conforms to the "ERC721
136 /// Metadata JSON Schema".
137 function tokenURI(uint256 _tokenId) external view returns (string memory);
138}
139
140/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
141/// @dev See https://eips.ethereum.org/EIPS/eip-721
142/// Note: the ERC-165 identifier for this interface is 0x780e9d63.
143interface IERC721Enumerable is IERC721 {
144 /// @notice Count NFTs tracked by this contract
145 /// @return A count of valid NFTs tracked by this contract, where each one of
146 /// them has an assigned and queryable owner not equal to the zero address
147 function totalSupply() external view returns (uint256);
148
149 /// @notice Enumerate valid NFTs
150 /// @dev Throws if `_index` >= `totalSupply()`.
151 /// @param _index A counter less than `totalSupply()`
152 /// @return The token identifier for the `_index`th NFT,
153 /// (sort order not specified)
154 function tokenByIndex(uint256 _index) external view returns (uint256);
155
156 /// @notice Enumerate NFTs assigned to an owner
157 /// @dev Throws if `_index` >= `balanceOf(_owner)` or if
158 /// `_owner` is the zero address, representing invalid NFTs.
159 /// @param _owner An address where we are interested in NFTs owned by them
160 /// @param _index A counter less than `balanceOf(_owner)`
161 /// @return The token identifier for the `_index`th NFT assigned to `_owner`,
162 /// (sort order not specified)
163 function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);
164}