I can't mint 1000 NFT items

Following the Moralis tutorial (https://www.youtube.com/watch?v=FcH7qXnOgzs&list=RDCMUCgWS9Q3P5AxCWyQLT2kQhBw) I’m trying to deploy this contract (remix.ethereum.org):

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// Import 1155 token contract from Openzeppelin
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";

// Contract to be deployed via https://remix.ethereum.org/
contract NFTContract is ERC1155, Ownable {
    using SafeMath for uint256;

    uint256 public count = 1000; // Number of files to mint

    constructor() ERC1155("ipfs://<FOLDER_HASH>/<SUBFOLDER_NAME>/{id}.json") {
        for (uint256 i = 1; i <= count; i++) {
            mint(msg.sender, i, 1);
        }
    }

    function mint(address account, uint256 id, uint256 amount) public onlyOwner {
        _mint(account, id, amount, "");
    }

    function burn(address account, uint256 id, uint256 amount) public {
        require(msg.sender == account);
        _burn(account, id, amount);
    }
}

The json files names are:

<FOLDER_HASH>/<SUBFOLDER_NAME>/0000000000000000000000000000000000000000000000000000000000000001.json
...
<FOLDER_HASH>/<SUBFOLDER_NAME>/0000000000000000000000000000000000000000000000000000000000001000.json

But the deployment seems to be stuck… it’s been over 30 minutes now. I am doing it right?

or should I write a 1000 lines instead of use a loop?

mint(msg.sender, 1, 1);
mint(msg.sender, 2, 1);
...
mint(msg.sender, 999, 1);
mint(msg.sender, 1000, 1);

If I try to do it with 1000 lines (instead of a loop) I get this error:

Oh my God… is this imposible to do? Help!

1 Like

Maybe I should use a lazy mint strategy… (I’ve been reading something regarding this)

Somebody knows how can I do it?

1 Like

@ekklesia : i cannot help you on this one but if you don’t find help enough fast on this forum, it is also strongly advised to ask help on the Moralis’ Discord channel. Subcribe to the Discord here : https://moralis.io/mage/
Normally, there is also a lot of people there that can help you very fast. Success !

1 Like

Hi @ekklesia
Try increasing gas and deploy

SOLVED! Using toString(16) for the JSON file names, instead of normal numeric names

0000000000000000000000000000000000000000000000000000000000000001.json (1)
0000000000000000000000000000000000000000000000000000000000000002.json (2)
0000000000000000000000000000000000000000000000000000000000000003.json (3)
0000000000000000000000000000000000000000000000000000000000000004.json (4)
0000000000000000000000000000000000000000000000000000000000000005.json (5)
0000000000000000000000000000000000000000000000000000000000000006.json (6)
0000000000000000000000000000000000000000000000000000000000000007.json (7)
0000000000000000000000000000000000000000000000000000000000000008.json (8)
0000000000000000000000000000000000000000000000000000000000000009.json (9)
000000000000000000000000000000000000000000000000000000000000000a.json (10)
000000000000000000000000000000000000000000000000000000000000000b.json (11)
000000000000000000000000000000000000000000000000000000000000000c.json (12)
000000000000000000000000000000000000000000000000000000000000000d.json (13)
000000000000000000000000000000000000000000000000000000000000000e.json (14)
000000000000000000000000000000000000000000000000000000000000000f.json (15)
0000000000000000000000000000000000000000000000000000000000000010.json (16)
0000000000000000000000000000000000000000000000000000000000000011.json (17)
0000000000000000000000000000000000000000000000000000000000000012.json (18)
...
00000000000000000000000000000000000000000000000000000000000003e7.json (999)
00000000000000000000000000000000000000000000000000000000000003e8.json (1000)

The problem is that I started following a tutorial in which the guy use normal numbers (because he only create 10 NFTs!), the moralis-mutants video. But then I have continued to watch other videos and it seems that they must be hex file names.

And creating a function to make the loop (instead of using the constructor directly, like in the tutorials)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// Import 1155 token contract from Openzeppelin
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";

// Contract to be deployed via https://remix.ethereum.org/
contract WEBContract is ERC1155, Ownable {
    using SafeMath for uint256;

    uint256 public items;

    constructor() ERC1155("ipfs://<FOLDER_HASH>/metadata/{id}.json") {
        items = 1000;
    }

    function mintAll() public onlyOwner {
        for (uint256 i = 1; i <= items; i++) {
            mint(msg.sender, i, 1);
        }
    }

    function mint(address to, uint256 id, uint256 amount) public onlyOwner {
        _mint(to, id, amount, "");
    }

    function burn(address from, uint256 id, uint256 amount) public {
        require(msg.sender == from);
        _burn(from, id, amount);
    }
}

TESTED ONLY WITH 22 ITEMS (and setting items = 22;)

I have claimed victory very quickly… With the test contract of only 22 items it worked for me (and I thought that would works with my real contract). I ended up seeing the 22 NFTs in testnet.opensea.io… But it turns out that with the 1000 of my real contract (on mainnet), the deploy in remix is frozen; deploy never ends. :frowning_face_with_open_mouth:

I give up… It’s not possible to mint 1000 items.

How can I increase gas? In the moralis tutorials (moralis-mutants-nfts) the guy doesn’t do anything with the gas…

you can do a deploy first and then call mintAll(), if that function executes than ell items should be minted

1 Like

I’ve tried on mombai testnet, increasing the gas limit to 3000000000 , the contract is deployed, but the mintAll function get me this error

you could try to do 100 at a time instead of 1000 in one transaction

1 Like

Yeah… how?

creating 10 functions?

mint1to100()
mint101to200()
and so on?

by using a parameter to a function, like how many nfts to mint

I wanna mint 1 of each NFT… but 1000 NFTs

So… I’m trying to understand the concept of “transaction”

Because if I create a function to _mint() 100 items and If I make a chain calling it 10 times… at the end is the same…

The way that I’m thinking is… creating 10 diferents methods, to call it one by one

mint1to100, mint101to200…, mint901to1000

But… it’s horrible!

you could make it somehow with a parameter maybe, to call same method with a number from 1 to 10 and to mint 100 nfts each time

1 Like

Yeah! step by step… I was able to create the collection (1000 items) in mumbai.polygon and see it in testnet.opensea… But when I do the deploy in mainnet.polygon… remix is still frozen; nothing happens… OMG… This is a nightmare. Do you know what could be going on?

I don’t know why it is frozen

Same contract, the only thing that changes is the network of the account with which I’m connected with Metamask. Mumbay OK. Deploying and minting. Mainnet KO. For me (without experience) has no sense. Maybe you don’t know the exact reason (because your are not viewing the logs), but, for the love of God, what changes using one network or other?. From my short experience, the unique thing that changes is whre you loose yout coins with the fees.

Maybe there is a problem with the RPC node