ERC721 standard – What should you pass in the name and symbol arguments passed to the constructor

contract-developmenterc-721nftopenzeppelinopenzeppelin-contracts

I've been confused about the ERC721 standard. We pass a name and symbol to the constructor. What do they represent? In the source code, it just says token name and token symbol.

Are they the name and symbol of an NFT? (Do NFTs have unique names & symbols?)

  • If so, then won't every NFT I mint using that contract have the same name and symbol?
  • Where do I specify the name of the collection that it belongs to?

Or are they the name and symbol of the collection to which the NFT belongs too? So that after I deploy the contract, every NFT I mint has that collection name and symbol.

  • I was looking at the contract of an NFT on OpenSea – link – and the name and symbol were of the collection that it belongs to (Kitty Crypto Gang (KCG)).

This is sample code from openzeppelin. The constructor is in line 8.

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract GameItem is ERC721URIStorage {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721("GameItem", "ITM") {} // constructor is here <---------------------

    function awardItem(address player, string memory tokenURI)
        public
        returns (uint256)
    {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(player, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }
}

Also, do NFTs have to be part of a collection? When I go to OpenSea, it seems that there are no individual NFTs. There are only collections.

Best Answer

First, to speak of the "name and symbol" of the "ERC-721 constructor" is not a thing. The constructor is not specified in the standard.

We must understand this question with the context as "what do the name and symbol of the OpenZeppelin Contracts implementation of ERC-721 mean?"

The name and symbol features of ERC-721 are defined in the ERC-721 specification

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

And further motivation is provided:

We have required name and symbol functions in the metadata extension. Every token EIP and draft we reviewed (ERC-20, ERC-223, ERC-677, ERC-777, ERC-827) included these functions.

We remind implementation authors that the empty string is a valid response to name and symbol if you protest to the usage of this mechanism. We also remind everyone that any smart contract can use the same name and symbol as your contract. How a client may determine which ERC-721 smart contracts are well-known (canonical) is outside the scope of this standard.

Related Topic