5

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".

Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69

1 Answers1

8

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.

Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69