I am currently creating a nft erc1155 project and am a bit confused in the coding. I currently have mine written as such.

uint public constant MILES_MORALES = 0
uint public constant GWEN_STACY = 1;

constructor() ERC1155() {
_mint(msg.sender, MILES_MORALES, 1, "");
_mint(msg.sender, GWEN_STACY, 1, "");


I have more variables declared and minted however I just wanted to keep it simple for the purpose of reading. I understand this is the gold standard to write a erc1155 contract however I have seen some people create it differently with more functionality and without minting in the constrcutor the way I did. What is the proper way to create a 1155 contract or at least to start out? And to I have to implement IERC1155 functionality? A bit confused here haha

1 Answer 1


For a smart contract to properly follow a standard ERC there are three things to be done:

  • Import the IERC (The Interface of the ERC).
  • Implement in your smart contract all the functions defined in the Interface.
  • Use of the IERC165 supportsInterface for external applications and contracts to verify that the contract complies with said Interface.

Once all the functions of the IERC are declared (following the same function header) you can however implement the functions the way you see fit.

There are indeed several common implementations of ERC1155.

=> Same stands for ERC721 with for instance ERC721A that uses the IERC721 and is therefore a compliant ERC721 smart contract, but implements function differently than seen before.

In Smart Contract development there is a giant, OpenZeppelin, that writes implementations that are battle tested, fully audited, documented, explained, supported and accessible. Therefore most Smart Contracts around ,instead of rewriting from scratch implementations of common standards, will simply use the OpenZeppelin's implementations.

However that doesn't mean that other implementations are wrong or shouldn't be used. (While still keeping in mind security & audits). The ERC1155 is for instance a perfect example of this:

  • ERC1155 was invented and written by the Enjin team
  • OpenZeppelin has written its own implementation of ERC1155. And OpenZeppelin being OpenZeppelin most developers will actually use their implementation
  • Enjin's implementation offers more complex functionalities than OZ's implementation.

In summary, as long as:

  • you comply with the Interface of the standard you are using, by implementing all its functions
  • you are implementing the IERC165 to verify standard compliance

You can use any implementation that you see fit, even write your own. Of course always keep in mind security.

If you are a bit lost on how to use a particular standard you can generally find that it is well documented on github or the implementer's website.

Here is the EIP's full explanation and rationale

Here is OpenZeppelin documentation

Enjin implementation code

OpenZeppelin implementation code

  • thank you so much for responding! This was incredibly helpful. I love Open Zepellin and use them as a resource very often and its actually a relief to hear programmers use it so often. So basically the core part of my smart contract is completed and all other functionality is subjective and depends on what I want to code as long as I implement all the functions that are standard? I have a bit of a habit of trying to make my code very complex when in reality it should be simple
    – EGstacking
    Commented Aug 12, 2023 at 23:52
  • I'm glad to hear it. If you think that this answers you question you can upvote it and choose it as the answer to your question :) As said, as long as you have all the function headers ,defined in the interface, re-declared in your contract you can implement the code inside as you see fit. Just keep in mind that if there isn't a proper reason to do it it's always better to use safe and tested code.
    – Torof
    Commented Aug 13, 2023 at 0:38
  • Since I am just starting out making my own projects I get a bit anxious haha. I try to make my code as complex as possible but realize that writing unecessary logic and code is a no go and I should get in the habit of making it as simple and effective as possible. Good to see there are so many resources out there now. So I am assuming most professional programmers dont write a lot of their code from scratch?
    – EGstacking
    Commented Aug 13, 2023 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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