3

I am running the substrate-node-template and I notice that the token symbol is UNIT and under the accounts tab in polkadot{.js} it shows up as MUNIT. How can I change my token symbol?

2
  • @Keith Yeung. First, thanks for your article. I just tried as you mentioned above but I got an error when run "cargo build --release" command. Here is my error. ![enter image description here](i.sstatic.net/Dd2jC.png) How can I fix this problem? Please teach me. Best Regards.
    – Super Boy
    Commented Jun 5, 2022 at 12:43
  • You need to add the missing import at the top of the file: use sc_service::Properties. If you are using the node-template, you can see that there's already an import of the sc_service, so you can extend it like use sc_service::{ChainType, Properties}; The rust compiler gives really good error handling and details on how to solve it.
    – andresvsm
    Commented Jun 6, 2022 at 5:43

1 Answer 1

10

One way you can change your token symbol is in the chain_spec.rs file, you can add something like this:

let mut properties = Properties::new();
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());

For example you can edit your chain_spec's development config like this:

pub fn development_config() -> Result<ChainSpec, String> {
    let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
    
    // Give your base currency a unit name and decimal places
    let mut properties = Properties::new();
    properties.insert("tokenSymbol".into(), "DOT".into());
    properties.insert("tokenDecimals".into(), 12.into());
    properties.insert("ss58Format".into(), 42.into());

    Ok(ChainSpec::from_genesis(
        // Name
        "Development",
        // ID
        "dev",
        ChainType::Development,
        move || {
            testnet_genesis(
                wasm_binary,
                // Initial PoA authorities
                vec![authority_keys_from_seed("Alice")],
                // Sudo account
                get_account_id_from_seed::<sr25519::Public>("Alice"),
                // Pre-funded accounts
                vec![
                    get_account_id_from_seed::<sr25519::Public>("Alice"),
                    get_account_id_from_seed::<sr25519::Public>("Bob"),
                    get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
                    get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
                ],
                true,
            )
        },
        // Bootnodes
        vec![],
        // Telemetry
        None,
        // Protocol ID
        None,
        // Properties
        Some(properties),
        // Extensions
        None,
    ))
}

Alternatively you can also make this change in the plain chain spec file. Take a look here: https://raw.githubusercontent.com/paritytech/polkadot/master/node/service/res/rococo.json

3
  • How to set initial token supply? Commented Mar 3, 2022 at 9:24
  • How to specify another different symbol if i have 2 native tokens of different type?
    – Rehan
    Commented Apr 8, 2023 at 21:09
  • 1
    You would need pallet assets for that.
    – Bruno
    Commented Apr 10, 2023 at 7:01

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.