DEV Community

Cover image for Symbol Mosaic Revocation Transaction In Metaverse
Anthony Law
Anthony Law

Posted on

Symbol Mosaic Revocation Transaction In Metaverse

Introduction

In the new catapult-client v1.0.3.0, Symbol has added a Mosaic Supply Revocation transaction type and a Revokable mosaic flag.

Mosaic Supply Revocation allows the mosaic creator to collect back any mosaics flagged as Revokable from whoever holds them, at anytime.

How it works

The Mosaic Supply Revocation transaction only works with Revokable Mosaics.

As an example, imagine a private property in the XYM City metaverse, where you must have access permission from the property owner to enter.

Let's assume a private property called Bull Fight Club. Users must own a BFC.daily-pass mosaic to enter the club, which can be purchased from the counter.

BFC Banner

Bull Fight Club will issue one BFC.daily-pass revokable mosaic to a user once received the 10 XYM payment.

Process

When daily pass expires, Bull Fight Club can issue a Mosaic Supply Revocation transaction to collect back the BFC.daily-pass without user interaction.

Mosaic Supply Revocation transaction

Example code

Create revokable mosaic

I just want to highlight the new code. Refer to the full example here.

When creating Revokable mosaics, I suggest you also make Transferable=false to prevent the recipient from transferring the mosaic to another account. Otherwise, recovering the mosaic will be harder.

const BFC_Operator = Account.createFromPrivateKey(privateKey, networkType);

const isSupplyMutable = true;
const isTransferable = false; <-- prevert recipient trasfer to other
const isRestrictable = true;
const isRevokable = true; <--- New flag

const nonce = MosaicNonce.createRandom();
const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create(
  Deadline.create(epochAdjustment),
  nonce,
  MosaicId.createFromNonce(nonce, BFC_Operator.address),
  MosaicFlags.create(isSupplyMutable, isTransferable, isRestrictable, isRevokable),
  0, // divisibility
  UInt64.fromUint(0), // duration
  networkType,
);
Enter fullscreen mode Exit fullscreen mode

Mosaic Supply Revocation transaction

This transaction allows the mosaic owner to collect back revokable mosaic from the specified holder.

const mosaicSupplyRevocationTransaction = MosaicSupplyRevocationTransaction.create(
  Deadline.create(epochAdjustment),
  holderAddress,
  new Symbol.Mosaic(new 
    Symbol.MosaicId('revokable_mosaic_id'), 
    Symbol.UInt64.fromUint(1)), // mosaic unit 
  networkType,
  maxFee,
)
Enter fullscreen mode Exit fullscreen mode

Summary

The Revokable mosaic flag and the Mosaic supply revocation transaction are super handy for the business operator who likes to control supply and reuse mosaics.

In my opinion, the benefit to using it is that the owner of the mosaic can easily control the mosaic supply, and collect back the mosaics without the user paying any fees. The downside is that the holder of the mosaic does not have any control over it.

Just be cautious, revokable mosaics are not suitable to represent currency/token or share. When doing any mosaic trading, always ensure you understand the mosaic flags and purpose. Keep in mind that any received revokable mosaics can be reclaimed at any time without your consent!

If you would like to know more about Symbol, please join the Discord.

Special thanks to Xavi for reviewing this article.

Discussion (0)