The ERC721 NFT standard API interface

The specification of the ERC721 standard interface that we are discussing in this section is taken from the EIP standard document at https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md.

The ERC721 NFT standard interface is defined as follows:

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);

function balanceOf(address _owner) external view returns (uint256);

function ownerOf(uint256 _tokenId) external view returns (address);

function safeTransferFrom(address _from, address _to,
uint256 _tokenId, bytes data)
external payable;

function safeTransferFrom(address _from, address _to,
uint256 _tokenId) external payable;

function transferFrom(address _from, address _to,
uint256 _tokenId) external payable;

function approve(address _approved, uint256 _tokenId) external payable;

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);
}

The preceding code defines the basic functions and events that an ERC721 NFT implementation must follow. We will discuss each of the functions and events in the upcoming sections.

As you can see in the code, the ERC721 interface also inherits from the ERC165 standard. The ERC165 standard is known as the Standard Interface Detection, using which we can publish and detect all interfaces a smart contract implements.

Please note that the preceding inheritance definition has the name ERC721. However, in OpenZeppelin's source code, the interface name is IERC721 and its implementation contract name is ERC721; hence, the reader should not be confused by the similarities in name.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.102.235