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?
1 Answer
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
-
-
How to specify another different symbol if i have 2 native tokens of different type?– RehanCommented Apr 8, 2023 at 21:09
-
1
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 likeuse sc_service::{ChainType, Properties};
The rust compiler gives really good error handling and details on how to solve it.