简体   繁体   中英

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:)

When deploying the contract, you can just pass in a different name in the string memory _name field

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM