Skip to content

Multi-chain Apps

Account Kit supports multi-chain apps, allowing you to build applications that interact with multiple blockchains. This guide will show you how to set up your app to work with multiple chains.

Update your config

In order to support multiple chains in your app, the first thing you need to do is update your createConfig call to include the chains you want to support.

import { createConfig } from "@account-kit/core";
import { sepolia, mainnet } from "@account-kit/infra";
 
export const config = createConfig({
  apiKey: "ALCHEMY_API_KEY",
  // this is the default chain
  chain: sepolia,
  chains: [
    {
      chain: mainnet,
      // optional: sponsor gas for this chain
      policyId: "MAINNET_GAS_MANAGER_POLICY_ID",
    },
    {
      chain: sepolia,
      // optional: sponsor gas for this chain
      policyId: "SEPOLIA_GAS_MANAGER_POLICY_ID",
    },
  ],
});

Change chains

Once your app is configured to use multiple chains, you can switch between them at any time using the setChain function.

example.ts
import { setChain } from "@account-kit/core";
import { mainnet } from "@account-kit/infra";
import { config } from "./config";
 
await setChain(config, mainnet);