I have deployed this contract that I have modified from the Moralis example in order to bulk mint 50 NFTs.
Here is the code.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.14;
// Import 1155 token contract from Openzeppelin
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract WEBContract is ERC1155, Ownable {
using SafeMath for uint256;
uint256 public items;
constructor() ERC1155("ipfs://QmSSqnAuYdU3sndc8AMgxVv74DMJeDfebkadKjWidgjqFv/metadata/{id}.json") {
items = 50;
}
function mintAll() public onlyOwner {
for (uint256 i = 1; i <= items; i++) {
mint(msg.sender, i, 2000000);
}
}
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);
}
}
The code works but I realized that sometimes the TokenID is not the same as the JSON equivalent.
For example, here the TokenID is 20 but the image that is minted is image #14, the JSON metadata is also for #14 instead of 20.
My question is, why is this happening?
I assume it has to do with the fact that the constructor is grabbing this {id} for JSON, so the indexer here is id, but in the loop, I am not using this id at all.
Instead, I am using this variable โiโ for the loop.
How can I include each JSON inside this loop, so that TokenID[1] mints the โ1.jsonโ file and so on until TokenID[50] mints โ50.jsonโ?