Rainbow logo
RainbowKit
1.0.5

Advanced

Custom chains

Create a custom chain

You can use the Chain type to help you create a custom chain. Then, pass that to the configureChains function.

For example, here's how you can create an Avalanche chain for avax.network.

import { Chain, getDefaultWallets } from '@rainbow-me/rainbowkit';
import { configureChains, createConfig, WagmiConfig } from 'wagmi';
import { Chain } from 'wagmi/chains';
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';
const avalancheChain: Chain = {
id: 43_114,
name: 'Avalanche',
network: 'avalanche',
iconUrl: 'https://example.com/icon.svg',
iconBackground: '#fff',
nativeCurrency: {
decimals: 18,
name: 'Avalanche',
symbol: 'AVAX',
},
rpcUrls: {
default: {
http: ['https://api.avax.network/ext/bc/C/rpc'],
},
},
blockExplorers: {
default: { name: 'SnowTrace', url: 'https://snowtrace.io' },
etherscan: { name: 'SnowTrace', url: 'https://snowtrace.io' },
},
testnet: false,
};
const { provider, chains } = configureChains(
[avalancheChain],
[
jsonRpcProvider({
rpc: chain => ({ http: chain.rpcUrls.default.http[0] }),
}),
]
);
const { connectors } = getDefaultWallets({
appName: 'My RainbowKit App',
projectId: 'YOUR_PROJECT_ID',
chains,
});
const wagmiConfig = createConfig({
autoConnect: true,
connectors,
provider,
});
const App = () => {
return (
<WagmiConfig config={wagmiConfig}>
<RainbowKitProvider chains={chains}>
<YourApp />
</RainbowKitProvider>
</WagmiConfig>
);
};

Learn more about configuring chains.