Skip to content

Minimal ERC721 Token

If you look at the official ERC721 Standard then you see there are a few mandatory and a few optional functionalities the smart contract needs to implement.

Luckily OpenZeppelin has us covered for most functions directly out of the box.

Let's have a look at a minimal example using the audited functions from OpenZeppelin.

Create a new file "MinimalERC721.sol" in the contracts folder and insert the following code:

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/token/ERC721/ERC721.sol";

contract MinimalERC721 is ERC721 {
    constructor() ERC721("Minimal", "MIN") {}
}

Before we can compile this we also have to change the truffle-config.js file. Open it and on the bottom you will find compiler settings. Set the version to 0.8.0 and enable the optimizer:

// Configure your compilers
  compilers: {
    solc: {
      version: "0.8.4",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
       settings: {          // See the solidity docs for advice about optimization and evmVersion
        optimizer: {
          enabled: true,
          runs: 200
        },
      //  evmVersion: "byzantium"
       }
    }
  },

then run truffle compile. It should output something like this:

Great!

Let's add a migration for the Token!


Last update: August 19, 2021