0

A blockchain I am working on enabled Frontier recently but since EVM chains' native tokens got 18 decimals by default and the chain's native token decimals are set to 12 we need to do decimals conversion for any EVM native token transfer and fee. Solving this creates compatibility issues when interacting with the chain using ether.js

Is it possible to chain the decimals of a native token on a chain that is already running (in our case changing the decimals to 18 so the token is EVM-compatible)? Does this require a hard fork or just a regular runtime upgrade would do the job?

2 Answers 2

1

decimals is not part of the genesis state, so you wouldn't need to reset the chain. Just set properties.tokenDecimals to 18 in the genesis chain spec of your chain:

{
    "name": "Polkadot CC1",
    "id": "polkadot_cc1",
    "chainType": "Live",
    /// -snip- ///
    "properties": {
        "ss58Format": 0,
        "tokenDecimals": 12, <===
        "tokenSymbol": "DOT"
    },
    /// -snip- ///
}

You can/should also update tokenDecimals in chain_spec.rs to have the same behaviour in local/dev networks.

Then, you will need to restart all the nodes with this new chain spec. And obviously, if you had any constants or values in the runtime related to token unit, you will also need to change them accordingly and perform the runtime upgrade:

- pub const UNIT: Balance = 1_000_000_000_000;
+ pub const UNIT: Balance = 1_000_000_000_000_000_000;
1

Previous answer is correct, but some additions:

You can technically avoid an upgrade and not touch any onchain state. Imagine, previously 1 UNIT was 10^12. Now it is 10^10. But this is a "new UNIT", so everyone still holds the same balance, only the denomination has changed.

DOT re-denominated after launch as well, but no onchain data was touched. Anyone who holds 1000 DOTs now, still holds "10 OLD DOTS" as well. Both of these are the same number onchain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.