4

If I have started running a Substrate node but the ss58Format value in the chain specification .json file that is generated from using the build-spec command is not 42, how do I update the chain so its SS58 Format is 42?

20220329 add:

i have updated system's SS58Prefix(set SS58Prefix=42),and upgrade wasm, but the ss58Format from rpc's response is not 42

how to update rpc's ss58Format?

const res = await api.rpc.system.properties()
console.log(res)

# ss58Format is not 42. 
1

2 Answers 2

2

The chain spec is no longer a canonical place to store the SS58 Prefix for a chain.

Instead you should use the SS58Prefix configuration constant in frame_system:

/// The designated SS85 prefix of this chain.
///
/// This replaces the "ss58Format" property declared in the chain spec. Reason is
/// that the runtime should know about the prefix in order to make use of it as
/// an identifier of the chain.
#[pallet::constant]
type SS58Prefix: Get<u16>;

This is how things like Polkadot JS API get the appropriate SS58 for your chain.

For your node binary, you want to be sure to call:

sp_core::crypto::set_default_ss58_version(ss58_version);

This value can come from the the runtime, or you can program whatever functionality you want. For example, in Polkadot, we don't actually pull the value from the chain spec, we just check which chainspec has been loaded, and then pull the SS58 from the registry:

fn set_default_ss58_version(spec: &Box<dyn service::ChainSpec>) {
    let ss58_version = if spec.is_kusama() {
        Ss58AddressFormatRegistry::KusamaAccount
    } else if spec.is_westend() {
        Ss58AddressFormatRegistry::SubstrateAccount
    } else {
        Ss58AddressFormatRegistry::PolkadotAccount
    }
    .into();

    sp_core::crypto::set_default_ss58_version(ss58_version);
}
1
  • Did a query on the URL you provided - under Developer -> Chain state -> Constants the system.ss58Prefix Shawn referenced returns 42.
    – Barto
    Commented Mar 30, 2022 at 12:33
1

42 is the default development prefix. To register an own prefix add it to the global registry - https://github.com/paritytech/ss58-registry.

Next update your on-chain system.ss58Prefix constant to reflect the above value and then udate the chain-spec (only needed for RPC nodes, most probably only used as a fallback where the on-chain constant is not available)

4
  • BTW, how to update chain-spec for a running node?
    – linus NG
    Commented Mar 25, 2022 at 1:18
  • Note that the ss58 registry is for non-test networks.
    – Squirrel
    Commented Mar 27, 2022 at 5:58
  • how update rpc response's ss58Format?
    – linus NG
    Commented Mar 29, 2022 at 15:13
  • 1
    Here is an example of how to update the chain spec: github.com/interlay/interbtc/commit/… Commented Mar 29, 2022 at 15:31

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.