How to do it…

  1. Create a new contract that inherits the BasicERC721 contract created in the previous recipe. This removes the need to declare the token and ownership properties:
pragma solidity ^0.4.23;import "./BasicERC721.sol";contract ERC721Token {    //...}
  1. A token can be transferred by the owner or by the approved person. The approval can be of two types. The user can set approval for one specific token or all the tokens owned by an address. Create two different mappings to maintain this:
// Mapping from token ID to approved addressmapping (uint256 => address) internal tokenApprovals;// Mapping from owner to operator approvalsmapping (address => mapping (address => bool)) internal operatorApprovals;
  1. Declare dedicated functions to verify ...

Get Ethereum Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.