📂Scheduled mint

How to get notified when the NFTs gets minted

The Scheduler mints your NFTs automatically.

// You need to create an SmartContract
const sc = await sdk.generateSmartContract({
    name: 'Test SDK',
    blockchain: 4,
    standard: 'ERC-1155',
    symbol: 'SDK',
    maxNFTs: 100,
    description: 'description',
    configuration: {
        mintPrice: 10
    }
});

//Or retrieve one that has not been deployed yet
const sc = await sdk.getSmartContract('6477098f222cdf6d9fd3c1dd');
//...
const nfts = sc.data.nfts;

If you want to get notified when your NFTs are minted, you can subscribe to the events Minteandome provides.

sdk.waitFor({type: MTMEvent.mint, }).subscribe({smartContractId, idNFTs} => {
    console.log('Minted NFTs:', idNFTs);
});

This subscription is very flexible and accepts some filters. In the example above, it will listen for all the minted NFTs that may happen. If you want to be more restrictive, you can use:

sdk.waitFor({
    type: MTMEvent.deploy,
    smartContractId: sc.data._id
}).subscribe({smartContractId, idNFTs} => {
    console.log('Minted NFTs:', idNFTs);
});

sdk.waitFor({
    type: MTMEvent.deploy,
    smartContractId: sc.data._id,
    idNFT: 3 // Specific NFT
}).subscribe({smartContractId, idNFTs} => {
    console.log('Minted NFTs:', idNFTs);
});

In this other example, it will listen only for that specific SmartContract minted NFTs, or for an specific NFT of an SmartContract. However, there is a better object oriented solution for this scenario:

// Get an instance of an SmartContract class
const sc = await sdk.getSmartContract('6477098f222cdf6d9fd3c1dd');

const nft = sc.data.nfts[0]; // First NFT

// Automatically unsubcribes after deployed
nft.onMint().subscribe({smartContractId, idNFT} => {
    console.log('Deployed SmartContract:', smartContractId);
});

Last updated