How to Handle Fractions (Decimal Amounts) of Native Tokens?

One thing I’ve noticed with the minting of, and other transactions involving native tokens, is that we only deal with integers.

This is well taken care of in the case of ADA and Lovelace… but how do we effectively and gracefully handle transactions involving fractions of native tokens?

What if we have existing assets from other blockchains that want to have cross-chain operations with Cardano and they want to preserve their overall total supply?

Many (if not all) of those assets allow for fractional holdings and not just whole units.

It would be weird and funny if for example, we have “TomatoCoin” that is supposed to have only 1,000 units in total circulating supply; and when we have to migrate some of the existing holders’ balances here in Cardano, their 0.1 TomatoCoin will suddenly have to be represented by 100,000 native tokens named “NativeTomatoCoin”…

…then we will just have to explain to them that they will have to divide that by 1,000,000 in order to get the correct equivalent of the original TomatoCoin.

The units for assets that you’re working with are equivalent of lovelaces, not ADA. Similar to how unit for base asset is lovelace. The notion of ADA is used by wallets and explorers.

That’s how we should treat them. So that’s supposed to be how these values are shown in wallet apps and chain explorers, right? They should be treated as 1/1,000,000 of the base unit.

But in Daedalus, they are displayed as is. Not in 1/1,000,000 of their values. (At least in the flight version 4.0.1)

The documentation is also not very clear on this. Perhaps this should be clarified?

The assets without any metadata associated are anyways albeit of a spam on blockchain. You can specify the unit in the asset metadata as per here

1 Like

:point_up_2: This answers my question. Thanks a lot!

Let me just clarify - is this asset metadata server already working on mainnet? If not, do we have a timeline for this already?

You can specify metadata already, yes. This data is offchain and would be queried by wallet layer/explorers (in very near future). There are step by step instructions here

Great to see this repo already populated. I actually checked it just yesterday and it was still empty! Thanks again @rdlrt!

Update: The empty repo I was talking about was this.

So, it appears the token metadata registry is not yet up. (as of Mar 9, 2021)


Any estimated or target dates when we can expect this service to be running?

1 Like

I know this topic is a litlte old, but I wanted to clarify a question on decimals. If I mint a token , do I account for the decimals at minting or after using the metadata…say I mint 1000 tokens which need 6 decimals, do I mint 1000 and then do the 6 decimals in the meta data later, or must I mint 1,000,000,000 and then enter the metadata in the registry as 6 decimals?

:point_up_2: this is what you need to do.

1 Like

Thank you for clarifying!

That issue cost me a bunch of time as I was not able to display the correct quantity of a minted token. Some tokens had no entries at all so the quantity is already given as presented. Others, I call them correct ones had a meta decimal entry specifying the decimal places. This showed again what a mess lives on the blockchain as well