Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I update my token's name in Substrate?

I have set up a custom Substrate chain, and I want to modify the display name of my token.

What do I need to modify such that Polkadot JS and other APIs can discover my token name?

By default it is "Unit".

like image 904
Shawn Tabrizi Avatar asked Mar 02 '23 20:03

Shawn Tabrizi


1 Answers

You can add the symbol and pass it to the Polkadot JS UI using the chainspec properties.

In chain_spec.rs import the use serde_json::json; and then:


    let mut props : Properties = Properties::new();

    let value = json!("USD");                          <--- (1)
    props.insert("tokenSymbol".to_string(), value);    <--- (2)

    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(props),        <------------------------------ (3)
        // Extensions
        None,
    ))

Notice the 3 highlighted lines above.

like image 188
Reza Mottie Avatar answered May 16 '23 08:05

Reza Mottie