📂Scheduled deploy (EVM blockchains)

How to get notified when the SmartContract gets deployed

The Scheduler deploys your SmartContracts 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');

If you want to get notified when your SmartContract is deployed, you can subscribe to the events Minteandome provides.

sdk.waitFor({type: MTMEvent.deploy}).subscribe({smartContractId} => {
    console.log('Deployed SmartContract:', smartContractId);
});

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

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

In this other example, it will listen only for that specific SmartContract deploy. However, if you only want to check when a single SmartContract has been deployed, the best option is to use object oriented solution:

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

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

Pending transactions

All of the examples above are from deployments by which their transactions have been completed. if you want early access to the pending transaction on the blockchain, you can use an extra param:

sdk.waitFor({
    type: MTMEvent.deploy,
    smartContractId: sc.data._id,
    pendingTransactions: true
}).subscribe({smartContractId, tx} => {
    console.log('Pending transaction:', tx);
});

Last updated