The /mosaics/{mosaicId}GET endpoint retrieves the current properties of a mosaic, including:
Supply: The total number of atomic units currently in circulation.
Do not confuse with the initial supply.
Divisibility: The number of decimal places the mosaic supports.
For example, XYM has a divisibility of 6, meaning 1 XYM equals 1,000,000 atomic units.
Flags: A bitmask encoding the mosaic's behavior restrictions.
Each flag occupies a single bit:
supply_mutable (1),
transferable (2),
restrictable (4),
and revokable (8).
Multiple flags combine additively. For example, a value of 6 means transferable (2) + restrictable (4).
Duration: The number of blocks the mosaic remains active.
A value of 0 means the mosaic never expires.
Start height: The block height at which the mosaic was created.
Revision: Incremented each time the mosaic definition is modified.
// Display formatted supplyconstsupply=BigInt(mosaic.supply);constdivisor=10n**BigInt(divisibility);constwhole=supply/divisor;constfractional=supply%divisor;constfractionalStr=fractional.toString().padStart(divisibility,'0');console.log(`\nSupply in whole units: ${whole}.${fractionalStr}`);
The supply value returned by the API is expressed in atomic units.
To convert it to whole units, the code divides the supply into whole and fractional parts
using the mosaic's divisibility.
For XYM (divisibility 6), a supply of 8325447775994408 atomic units equals 8325447775.994408 whole units.
// Fetch namespace names linked to the mosaicconsole.log(`\nFetching namespace names for mosaic ${MOSAIC_ID}`);constnamesResponse=awaitfetch(`${NODE_URL}/namespaces/mosaic/names`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({mosaicIds:[MOSAIC_ID]})});constnamesInfo=awaitnamesResponse.json();for(constentryofnamesInfo.mosaicNames){if(entry.names.length>0){console.log(' Namespace aliases:',entry.names.join(', '));}else{console.log(' No namespace aliases linked');}}
Mosaics can be linked to human-readable namespace aliases.
The /namespaces/mosaic/namesPOST endpoint accepts mosaic IDs and returns any namespace names currently linked to
them.
A mosaic can have multiple namespace aliases if different namespaces link to the same mosaic.
If no namespace is linked, the response indicates that no aliases exist.