Get asset metadata

Get metadata of a specific asset.

Example - Asset Registry & Token Registry

const asset = 'IYzTSjJg4I3hvUaRXrihRm9+mSEShenPK8l8uKUOD3o=';

client.api.getAssetMetadata(asset, function(err, registry_unit) {
  if (err) return console.error(err);
  client.api.getJoint(registry_unit.metadata_unit, function(err, result) {
    if (err) return console.error(err);
    const metadata = result.joint.unit.messages.find(item => item.app == 'data');
    console.log(registry_unit, metadata ? metadata.payload : null);
  });
});

Returns

{
  metadata_unit: "0xXOuaP5e3z38TF5ooNtDhmwNkh1i21rBWDvrrxKt0U=",
  registry_address: "AM6GTUKENBYA54FYDAKX2VLENFZIMXWG",
  suffix: null
}
{
  asset: "IYzTSjJg4I3hvUaRXrihRm9+mSEShenPK8l8uKUOD3o=",
  decimals: 0,
  name: "WCG Point by Byteball",
  shortName: "WCG Point",
  issuer: "Byteball",
  ticker: "WCG",
  description: "WCG Point is a honorific token, a recognition of contributing to World Community Grid projects. The token is not transferable, therefore, it cannot be sold and the balance reflects a lifetime contribution to WCG. Some services might choose to offer a privilege to users with large balance of this token."
}

Example - Token Registry only

const symbol = 'TONY';
const asset = 'fAmGezsOuWr6TEkUmKA6zYDZUUzeE0j95pvPgIcgTkM=';
const registry = client.api.getOfficialTokenRegistryAddress();
client.api.getAssetBySymbol(registry, symbol).then(console.log);
client.api.getSymbolByAsset(registry, asset).then(console.log);
client.api.getDecimalsBySymbolOrAsset(registry, symbol).then(console.log);
client.api.getDecimalsBySymbolOrAsset(registry, asset).then(console.log);

Returns

fAmGezsOuWr6TEkUmKA6zYDZUUzeE0j95pvPgIcgTkM=
TONY
9
9

Learn more

Last updated