Skip to content

useSs58Format

The useSs58Format hook provides access to the SS58 address format prefix of the connected chain.

Import

tsx
import { useSs58Format } from '@luno-kit/react'

Usage

tsx
import { useSs58Format } from '@luno-kit/react'

function Ss58FormatDisplay() {
  const { data: ss58Format, isLoading } = useSs58Format()
  
  if (isLoading) {
    return <div>Loading SS58 format...</div>
  }
  
  if (!ss58Format) {
    return <div>No SS58 format available</div>
  }
  
  return (
    <div>
      <h3>SS58 Format</h3>
      <p>Prefix: {ss58Format}</p>
    </div>
  )
}

function getSs58Description(format: number): string {
  switch (format) {
    case 0: return 'Polkadot (0)'
    case 2: return 'Kusama (2)'
    case 42: return 'Substrate (42)'
    default: return `Custom (${format})`
  }
}
ts
import { createConfig, kusama, polkadot, polkadotjsConnector } from '@luno-kit/react'

const config = createConfig({
  appName: 'luno with-vite example',
  chains: [polkadot, kusama],
  connectors: [polkadotjsConnector()],
  autoConnect: true,
});

Return Value

The hook returns an object with the following properties:

PropertyTypeDescription
datanumber | undefinedThe SS58 address format prefix
isLoadingbooleanWhether the SS58 format is currently loading

SS58 Format Values

The data property represents the SS58 address format prefix used by the chain.

ValueDescriptionExample Chain
0PolkadotPolkadot mainnet
2KusamaKusama mainnet
42SubstrateSubstrate development chains
CustomChain-specificOther networks

TIP

The hook first attempts to fetch the SS58 format from the chain's runtime constants. If that fails, it falls back to the chain configuration or defaults to 42 (Substrate format).

Released under the MIT License.