Skip to content

Custom Chains

Learn how to add support for custom Substrate-based chains and configure them for use with LunoKit.

Overview

LunoKit supports almost any Substrate-based blockchain. This guide shows you how to define custom chains, configure their properties, and integrate them with your application.

Basic Custom Chain

tsx
import { createConfig } from '@luno-kit/react'
import { defineChain } from '@luno-kit/react/utils'

const myCustomChain = defineChain({
  genesisHash: '0x123...',
  name: 'My Custom Chain',
  nativeCurrency: {
    name: 'Custom Token',
    symbol: 'CUSTOM',
    decimals: 12,
  },
  rpcUrls: {
    webSocket: ['wss://rpc.mycustomchain.com'],
  },
  ss58Format: 42,
  testnet: true,
  chainIconUrl: 'https://example.com/icon.png',
})

const config = createConfig({
  appName: 'My App',
  chains: [myCustomChain],
  connectors: [polkadotjsConnector()],
})

Parachain Configuration

tsx
// Acala parachain example
const acalaChain = defineChain({
  genesisHash: '0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c',
  name: 'Acala',
  nativeCurrency: {
    name: 'Acala',
    symbol: 'ACA',
    decimals: 12,
  },
  rpcUrls: {
    webSocket: ['wss://acala-rpc-0.aca-api.network'],
    http: ['https://acala-rpc-0.aca-api.network'],
  },
  ss58Format: 10,
  testnet: false,
  chainIconUrl: 'https://icons.llamao.fi/icons/chains/rsz_acala.jpg',
  blockExplorers: {
    default: { name: 'Subscan', url: 'https://acala.subscan.io' },
  },
  subscan: {
    api: 'https://acala.api.subscan.io',
    url: 'https://acala.subscan.io',
  },
})

// Moonbeam parachain example
const moonbeamChain = defineChain({
  genesisHash: '0xfe58ea77779b7abda7da4ec526d14db9b1e9cd40a217c34892af80a9b332b76d',
  name: 'Moonbeam',
  nativeCurrency: {
    name: 'Glimmer',
    symbol: 'GLMR',
    decimals: 18,
  },
  rpcUrls: {
    webSocket: ['wss://wss.api.moonbeam.network'],
    http: ['https://rpc.api.moonbeam.network'],
  },
  ss58Format: 1284,
  testnet: false,
  chainIconUrl: 'https://moonbeam.network/wp-content/uploads/2021/01/Moonbeam-Logo.png',
  blockExplorers: {
    default: { name: 'Moonscan', url: 'https://moonscan.io' },
  },
})

Asset List(optional)

For chains that support Asset List, you can configure Subscan API endpoints to enable enhanced AssetList functionality:

tsx
const myChain = defineChain({
  // ... other chain properties
  subscan: {
    api: 'https://polkadot.api.subscan.io',  // Subscan API endpoint
    url: 'https://polkadot.subscan.io',      // Subscan explorer URL
  },
})

This configuration works together with the global Subscan API key in your createConfig to provide enhanced asset information.

TIP

The subscan.api should match the chain's Subscan API endpoint. For example, Polkadot uses https://polkadot.api.subscan.io, while Kusama uses https://kusama.api.subscan.io.

Chain Properties Reference

PropertyTypeRequiredDescription
genesisHashstringYesUnique identifier for the chain
namestringYesHuman-readable chain name
nativeCurrency{ name: string; symbol: string; decimals: number }YesNative token configuration
rpcUrls{ webSocket: readonly string[]; http?: readonly string[] }YesRPC endpoint URLs
ss58FormatnumberYesAddress format for the chain
testnetbooleanYesWhether the chain is a testnet
chainIconUrlstringYesURL to chain icon
blockExplorers{ default?: { name: string; url: string }; [key: string]: { name: string; url: string } | undefined }NoBlock explorer configuration
subscan{ api: string; url: string }NoSubscan API endpoint and explorer URL configuration for enhanced asset data

Released under the MIT License.