Can someone show me an example of how _mintBatch and js interact

Hi all. Pardon my impertinence, I am using this material by Moralis. I also load my data into IPFS differently than what is shown here.
How to Bulk Mint NFTs
Since I’m not doing it the way it says here, it doesn’t fucking work. Can someone show me an example of how _mintBatch and js interact. That is, how to do it, if you can a simple example, because I am new to creating smart contracts and I don’t know how to call and deploy them in essence. Thanks!
PS I am trying to use the 1155 protocol. I have a list of references to files loaded in IPFS, and now I’m trying to call the constructor as specified in the Moralis example. But it doesn’t work the way I want it to because there is no JS. If I understood how to call from JS and pass those {id} links inside, maybe I could finally deploy the contract in the test network.

You can use this method to use _mintBatch. Web3 Provider - Moralis

This is a way to interact with your deployed contracts. The constructor is run on contract deployment, you don’t call this after.

If you have your IPFS metadata links all set up and the base link used in the constructor when you deploy the contract, then for _mintBatch you would just need to pass in all the token ids and amounts.

1 Like

constructor(uint256[] memory _number, uint256[] memory _count) ERC1155(“{id}”) {
number = _number;
count = _count;
_mintBatch(msg.sender, _number, _count, “0x00”);
Can you tell me how to correctly specify each {id}. That is, I have all the metadata files and all the work files they are uploaded through the Moralis service as files Moralis Has Native Support for IPFS. Now I would like to understand how exactly I should replace these id’s in the constructor. & thanks

What does the token_uri for your token_id of 1 look like? What you put in the constructor will depend on this.

Clients or apps like OpenSea will change {id} with the correct link. This is part of the ERC1155 standard Read a bit about this here.

id_1 looks just like an ipfs Moralis link. I don’t have the numbering they specify everywhere. But I do have the links that Moralis returned to me when I used file uploads. So it looks like this: 1. I first uploaded the image through Moralis to IPFS 2. Moralis returned me the address to my file on the ipfs network. 3. By software method, I inserted this link in image_uri into my database and then created a json file based on this where all the metadata is filled in as I need it. 4. I filled the json file again via Moralis in ipfs

To put it simply, I’m still dumb in the matter of working with a smart contract. So I’m trying to figure out how to call _mintBatch in such a way, that my references are directed there - to the constructor. That is, I know how to make a list with these ipfs links to JSON files that I loaded earlier. I just don’t know how to call this function via JS so that this list will be completely passed.
So far, I’ve learned this:
web3.eth.defaultAccount = web3.eth.accounts[0];
var mycontract = web3.eth.contract(myABI);
var Coursetro =‘0xb8EAa27692AF5E6e7ed1bB88CD789707c878E3a2’);
And then I don’t know how to call _mintBatch

It’s a little more complicated than what’s written in the manuals I read. Usually JSON file is created in JS, but my JSON file is yes you are right for OpenSea, and there is a lot of filling. The JSON file is created in the desktop program by another one, based on the database data. That’s why I first fill files - pictures in ipfs through Moralis. And then I create with their uri JSON files through another program

For example, this is a list of valid ERC1155 token_uris for a collection.

And then the contract for that example looked like:

contract NFTContract is ERC1155, Ownable {
    using SafeMath for uint256;


Can we get an example of an actual token_uri link? It needs to be similar to that above. Need to verify these things are correct first before worrying about _mintBatch.

This is a test link to a json file with a test set of attributes.

So I can make an array of such references, now I would like to understand how exactly I can implement _mintBatch with a set of references, that is essentially a set of {id}. And if you can enlighten me how to pass public variables to my smart contract via web3.js I will be very glad. I mean I pass _number and _count to the constructor more precisely I want to pass _number and _count. But how to initialize them in the js I don’t know yet

So from that I understood that I initialized my contract, now I’m trying to figure out how to call the function I need and pass the arguments beforehand to the constructor itself. I should at least understand at the moment how to implement call of function _mintBatch with passing of address list to it.

So that won’t work for ERC1155. This tutorial should cover the basics:

Generate NFTs with this simple code (this could make you millions) PART 1 - YouTube

Again, do not worry about the contract interaction (you will likely have to redeploy anyway) until you sort out the correct format for your token_uris.

ok, thank you very much