ZigZag

Utilities

Helper functions and pre-built groups provided by @zig-zag/chains.

Chain Groups

Pre-built arrays for common filtering needs:

import {
  allChains,        // All 20 chains
  relayChains,      // Polkadot, Kusama, Westend, Paseo
  systemChains,     // Asset Hub, People, Coretime, Collectives, Bridge Hub
  parachainChains,  // Astar, Acala, Moonbeam, Phala, Hydration
  testnetChains,    // Westend, Paseo, Westend Asset Hub, Paseo Asset Hub
  mainnetChains,    // Everything except testnets
} from '@zig-zag/chains';

Lookup Helpers

getChainById

Look up a chain by its numeric ID:

import { getChainById } from '@zig-zag/chains';

const chain = getChainById(0);
console.log(chain?.name); // "Polkadot"

getChainByNetwork

Look up a chain by its network slug:

import { getChainByNetwork } from '@zig-zag/chains';

const chain = getChainByNetwork('kusama');
console.log(chain?.name); // "Kusama"

getChainByGenesisHash

Look up a chain by genesis hash:

import { getChainByGenesisHash } from '@zig-zag/chains';

const chain = getChainByGenesisHash('0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3');
console.log(chain?.name); // "Polkadot"

All lookups return Chain | undefined.

Define Custom Chains

Use defineChain to create chain objects that satisfy the Chain interface with full type inference:

import { defineChain } from '@zig-zag/chains';

const myChain = defineChain({
  id: 99999,
  name: 'My Chain',
  network: 'my-chain',
  genesisHash: '0xabcdef...',
  ss58Format: 42,
  nativeCurrency: { name: 'My Token', symbol: 'MYT', decimals: 12 },
  rpcUrls: { default: 'wss://rpc.my-chain.io' },
});

On this page