Skip to content

Mosaic supply change transaction

Eleazar Garrido edited this page Jan 13, 2019 · 6 revisions

Mosaic supply change transaction

Mosaic supply change transaction is used to assign supply to a mosaic.

  • Following parameters are required:
    • Mosaic Id
      • Combination of namepsace name and mosaic name. For example “foo.bar:xpx”.
    • Direction
      • Could be Increase (0) or Decrease (1).
    • Delta
      • The amount of supply to increase or decrease.
mosaicId, _ := sdk.NewMosaicIdFromFullName("newnamespace:mymosaic")
direction := 1
delta := big.NewInt(100000000000)

mosaicSupplyChange, err := sdk.NewMosaicSupplyChangeTransaction(
	sdk.NewDeadline(time.Hour*1),
	mosaicId,
	sdk.MosaicSupplyType(direction),
	delta,
	sdk.MijinTest,
)

// Sign transaction
stx, err := acc.Sign(mosaicSupplyChange)
if err != nil {
	panic(fmt.Errorf("NewMosaicSupplyChangeTransaction signing returned error: %s", err))
}

// Announce transaction
restTx, err := client.Transaction.Announce(context.Background(), stx)
if err != nil {
	panic(err)
}
fmt.Printf("%s\n", restTx)
fmt.Printf("Hash: \t\t%v\n", stx.Hash)
fmt.Printf("Signer: \t%X\n\n", acc.KeyPair.PublicKey.Raw)