Hello everyone,
I'm currently working on an NFT project, using the openzeppelin ERC721 standard for the nfts.
When Inheriting the ERC721 NFT contract standard from openzeppelin you're required to pass in the "tokenName" and "tokenSymbol" for the nft in the constructor.
My issue with this is that in order to do this I need to hard-code the name of the nft and symbol into the contract before deploying. I don't want that, I want to be able to create different NFTs with different names and symbols.
Instead of hard coding, I want to be able to give the NFTs a dynamic name and a symbol from the constructor, when I deploy the contract.
solidity version 0.8.4
This is a regular ERC721 constructor from openzeppelin;
Token name "Metaverse Tokens" and symbol "METT" are hard-coded into the contract.
constructor (address marketPlaceAddress) ERC721 ("Metaverse Tokens", "METT") {
contractAddress = marketPlaceAddress;
}
This is my modified code;
Token name and symbol are collected as inputs from the constructor in the contract.
constructor (address Dispenser, string memory _tokenName, string memory _tokenSymbol)
ERC721 ( tokenName , tokenSymbol) {
// use Dispenser address to deploy NFT contract
contractAddress = Dispenser;
// set the name of the token
tokenName = _tokenName;
// set the symbol of the token
tokenSymbol = _tokenSymbol;
// set the tokenCount to 0 on deployment
tokenCount = 0;
}
The issue with my code is that it doesn't pass in the name and symbol to the ERC721 contract that it inherits from, but the unmodified code passes them(name & symbol) in.
So my questions are as follows;
- How do you pass in a variable as a string to a constructor in solidity
- Am I on the right track with my code? and What do I need to change with my code to make this work
- Does the openZeppelin ERC721 contract not support this?
- Am I on the wrong track, and do you think I'm asking the wrong question
Please help