[Ethereum] How to creating multiple NFT tokens using ERC1115

erc-1155erc-721soliditytruffleweb3js

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.

Best Answer

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

Related Topic