/// ERC-165 0x80ac58cd.
interface ERC721 /* is ERC165 */ {
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
/// owner 有多少个 NFT
function balanceOf(address _owner) external view returns (uint256);
/// NTF 的 owner
function ownerOf(uint256 _tokenId) external view returns (address);
/// 转让 NTF 所有权
/// 会确认 _to 实现 IERC721Receiver - onERC721Received(address,address,uint256,bytes)
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;
/// 同带 data 的 safeTransferFrom - data 默认为 空
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
/// 转让 NTF 所有权
/// msg.sender 为 owner 或 批准地址
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
/// 批准 _approved 进行操作
/// 事件: Approval
function approve(address _approved, uint256 _tokenId) external payable;
/// 批准 _operator 操作所有 NTF
/// 事件: ApprovalForAll
function setApprovalForAll(address _operator, bool _approved) external;
function getApproved(uint256 _tokenId) external view returns (address);
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}
/// ERC-165 0x150b7a02.
interface ERC721TokenReceiver {
/// transfer 到合约的回调
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) external returns(bytes4);
}
/// 可选元数据扩展接口
/// ERC-165 0x5b5e139f
interface ERC721Metadata /* is ERC721 */ {
/// @notice A descriptive name for a collection of NFTs in this contract
function name() external view returns (string _name);
/// @notice An abbreviated name for NFTs in this contract
function symbol() external view returns (string _symbol);
/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
/// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
/// 3986. The URI may point to a JSON file that conforms to the "ERC721
/// Metadata JSON Schema".
function tokenURI(uint256 _tokenId) external view returns (string);
}
/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// Note: the ERC-165 identifier for this interface is 0x780e9d63.
interface ERC721Enumerable /* is ERC721 */ {
/// @notice Count NFTs tracked by this contract
/// @return A count of valid NFTs tracked by this contract, where each one of
/// them has an assigned and queryable owner not equal to the zero address
function totalSupply() external view returns (uint256);
/// @notice Enumerate valid NFTs
/// @dev Throws if `_index` >= `totalSupply()`.
/// @param _index A counter less than `totalSupply()`
/// @return The token identifier for the `_index`th NFT,
/// (sort order not specified)
function tokenByIndex(uint256 _index) external view returns (uint256);
/// @notice Enumerate NFTs assigned to an owner
/// @dev Throws if `_index` >= `balanceOf(_owner)` or if
/// `_owner` is the zero address, representing invalid NFTs.
/// @param _owner An address where we are interested in NFTs owned by them
/// @param _index A counter less than `balanceOf(_owner)`
/// @return The token identifier for the `_index`th NFT assigned to `_owner`,
/// (sort order not specified)
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);
}