Search code examples
ethereumsoliditynfterc721

Create two different instances of ERC-721 in the same smart contract


So I want to create two different kind of NFTs, each one with its own name, but I don't want to create two different smart contracts and duplicate my code. I don't know if its possible, but it is worth asking. Sorry if it's an stupid question.

constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol)

I instantiate it like this, so maybe it could be posible to instantiate two of them? idk. Thanks :)


Solution

  • this question is difficult to understand, do you want to create two ERC721 smart contracts and merge them into one (so that you have collection 1 and collection 2 in one contract)?

    if you mean this there are two answers, one long and one short.

    the short answer: you simply can't

    the long answer: starting from a basic ERC721 you can modify and above all add functions which refer to collection 1 and others to collection 2

    but this would take you out of the ERC721 standard, with the risk that your contract will no longer be sure, but above all they would not be visible and interactable by non-expert users, having come out of the standard, no existing Dapp supports such a thing, you should create your own Dapp.