Modifying mosaic supply

Alter the supply of a mosaic following this guide.

Prerequisites

Let’s get 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 mosaic supply change transaction setting the target mosaicId.

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

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

const mosaicId = new MosaicId([520597229,83226871]); // Replace with your mosaicId

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

const signedTransaction = account.sign(mosaicSupplyChangeTransaction);

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 mosaicId = new MosaicId([520597229,83226871]); // Replace with your mosaicId

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

const signedTransaction = account.sign(mosaicSupplyChangeTransaction);

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

What’s next?

Decrease your mosaic supply by changing MosaicSupplyType.Increase to MosaicSupplyType.Decrease.