0

native token of my chain has 12 decimals,now i have integrated EVM functionality into my chain, is there any way by which i can change evm decimals from 18 to 12 as i don't want to change my native token decimals???

2 Answers 2

3

You should, and I recommend changing your native token decimals. Otherwise, you need a converter.

Then, I have a question.

Why do you need EVM? This will break almost every existing thing (such as smart contract). EVM's goal is to mock Ethereum and re-use the existing infrastructures. And the third-party developers will be so confused while developing base on your chain.


Here https://github.com/darwinia-network/darwinia-common/blob/6a9392cfb9fe2c99b1c2b47d0c36125d61991bb7/frame/dvm/ethereum/src/adapter.rs#L136.

Darwinia has been running for over 2 years. Finally, we give up on maintaining this. We change the decimal to 18. So, that's my suggestion.

2
  • Xavier thanks for your response , we want EVM functionality in our chain, and its been more than 1 yr our chain is live so we want to add EVM functionality. we want a solution for token decimals as our native token has 12 decimals.can you tell me something about converter. Jan 13, 2023 at 7:51
  • 1
    Answer updated. Jan 13, 2023 at 8:43
0

In order to change the decimals of your native token you have to modify your chain_spec.rs file. Import in the node/Cargo.toml sc-chain-spec

[dependencies.sc-chain-spec] 
branch = 'master'
git = "https://github.com/paritytech/substrate"

And in the function development_config() or local_testnet_config() add your properties:

let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenDecimals".into(), 12.into());

And finally add in properties: of the from_genesis call:

// Properties
Some(properties), 

See an example in the Parachain Template Node

1
  • alex thanks for your response but i don't need this. Jan 13, 2023 at 7:52

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.