0

I am new to solidity and ethereum network. I have knowledge of developing erc20 and erc721 tokens using openzepplin. But I am curious about erc1155. Also I have check the erc1155 documentation at https://eips.ethereum.org/EIPS/eip-1155

What I want to achieve is to generate multiple erc-721 NFT tokens using erc1155

  1. Token 1 with 100 supply
  2. Token 2 with 500 supply
  3. Token 3 with 1000 supply

and mint these tokens with 1 transaction to contract creator account while deploying the contract.

I couldn't find any resources regarding this. Any guidance or help would be appreciated.

1
  • Here's a slightly related question - why do you want to do this as an ERC1155 token, instead of creating three different ERC20 tokens with 100, 500, and 1000 supply?
    – tjr226
    Commented Apr 7, 2021 at 23:14

1 Answer 1

0

OpenZepplin ERC1155

// contracts/GameItems.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract GameItems is ERC1155 {
    uint256 public constant GOLD = 0;
    uint256 public constant SILVER = 1;
    uint256 public constant THORS_HAMMER = 2;
    uint256 public constant SWORD = 3;
    uint256 public constant SHIELD = 4;

    constructor() public ERC1155("https://game.example/api/item/{id}.json") {
        _mint(msg.sender, GOLD, 10**18, "");
        _mint(msg.sender, SILVER, 10**27, "");
        _mint(msg.sender, THORS_HAMMER, 1, "");
        _mint(msg.sender, SWORD, 10**9, "");
        _mint(msg.sender, SHIELD, 10**9, "");
    }
}

The constants on the top create different NFTs. By using the mint function you can mint those NFTs as shown in the constructor function

2
  • I have a question, will this mint erc721 tokens? I am looking to mint erc 721 tokens using 1155? What I think is that it will mint 1155 tokens. Which are not currently visible on etherescan. Commented Mar 12, 2021 at 4:22
  • @CreativeDip No this will make ERC1155 NFTs. ERC1155 Allows for multiple NFTs to exist on the same smart contract but it is its on standard. As for viewing on etherscan dont know when it will be possible
    – Bryant
    Commented Mar 12, 2021 at 5:45

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.