Modifying mosaic supply

Alter the supply of a mosaic following this guide.

Prerequisites

Getting into some code

If you have followed the previous guide, right now you should own a supply mutable mosaic.

To increase the initial supply to 2.000.000, define a MosaicSupplyChangeTransaction replacing your target mosaic identifier in the next code snippet.

const transactionHttp = new TransactionHttp('http://localhost:3000');

const privateKey = process.env.PRIVATE_KEY as string;
const account = Account.createFromPrivateKey(privateKey, NetworkType.MIJIN_TEST);

const mosaicIdHexa = process.env.MOSAIC_ID_HEXA as string;
const mosaicId = new MosaicId(mosaicIdHexa);

const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create(
    Deadline.create(),
    mosaicId,
    MosaicSupplyChangeAction.Increase,
    UInt64.fromUint(2000000),
    NetworkType.MIJIN_TEST);

const networkGenerationHash = process.env.NETWORK_GENERATION_HASH as string;
const signedTransaction = account.sign(mosaicSupplyChangeTransaction, networkGenerationHash);

transactionHttp
    .announce(signedTransaction)
    .subscribe(x=> console.log(x), err => console.error(err));
const transactionHttp = new TransactionHttp('http://localhost:3000');

const privateKey = process.env.PRIVATE_KEY;
const account = Account.createFromPrivateKey(privateKey, NetworkType.MIJIN_TEST);

const mosaicIdHexa = process.env.MOSAIC_ID_HEXA;
const mosaicId = new MosaicId(mosaicIdHexa);

const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create(
    Deadline.create(),
    mosaicId,
    MosaicSupplyChangeAction.Increase,
    UInt64.fromUint(2000000),
    NetworkType.MIJIN_TEST);

const networkGenerationHash = process.env.NETWORK_GENERATION_HASH;
const signedTransaction = account.sign(mosaicSupplyChangeTransaction, networkGenerationHash);

transactionHttp
    .announce(signedTransaction)
    .subscribe(x=> console.log(x), err => console.error(err));

What’s next?

You can decrease a mosaic supply by changing MosaicSupplyType.Increase to MosaicSupplyType.Decrease.