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
andsymbol
features of ERC-721 are defined in the ERC-721 specificationAnd further motivation is provided: