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 { defineChain, createConfig } from '@luno-kit/react'

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: [polkadotjs()],
})

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' },
  },
})

// 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' },
  },
})

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

Released under the MIT License.