2

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.

2 Answers 2

2

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.

1
2

ERC-721 for the most part extends ERC-20. ERC-20 can have properties like name and symbol, eg Chainlink (LINK). In ERC-721, it's similar, only that it's the name and symbol of all the NFT's in that contract. Additionally, each NFT will also have a unique tokenId. The name and symbol, can be considered to denote the collection.

If you want just a single NFT, you can define the total supply to be 1. But it's often the case that NFTs are minted as a collection, although there are a few examples of single NFTs in ERC-721 contracts.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.