Bridge Kit

Adapter Setups

Bridge Kit uses adapters to abstract away the complexity of different blockchain architectures. Adapters handle all blockchain-specific bridging operations for a particular network.

The following table shows ways to set up adapters and when to use each one.

Setup methodDescriptionUse case
StandardStandard setup that creates an adapter from a private wallet key. Uses default built-in public RPC endpoints and factory functions.Testing environments where you want to get started quickly without configuring RPCs.
Custom RPCPrivate key setup that lets you configure an RPC endpoint.Production environments that need reliable RPCs.
Browser walletUses an injected wallet provider, such as MetaMask or Phantom, to create an adapter in the browser.Browser environments using wallet providers.

Bridge Kit works with these adapter libraries:

  • viem v2: for EVM-compatible chains
  • ethers: v6 for EVM-compatible chains
  • solana: for the Solana blockchain

Pick one Ethereum adapter (either Viem or Ethers). Add the Solana adapter only if you want transfer to or from Solana.

This is the easiest way to start. You create one adapter from your wallet's private key to transfer tokens between EVM-compatible blockchains. You can also add the Solana adapter to transfer tokens to or from Solana.

This setup uses public RPC endpoints and factory functions. For production, you should configure a custom RPC. Public connections have rate limits and might be slow.

Select the tab to see code examples for your adapter choice.

  • Viem
  • Ethers
  • Solana

This code block initializes the Viem adapter to transfer tokens between EVM-compatible chains:

Typescript
import { createAdapterFromPrivateKey } from "@circle-fin/adapter-viem-v2";

const adapter = createAdapterFromPrivateKey({
  privateKey: process.env.PRIVATE_KEY as string,
});

You can replace the public RPC from the standard setup with your own connection. For production, you should use a paid service like Alchemy or QuickNode. These services are more reliable than free connections.

The following code shows how to set up your own RPC. Pick your adapter to see the code.

  • Viem
  • Ethers
  • Solana

To use your own connection, replace the default one and add your custom RPC endpoint. This example uses an Alchemy connection:

Typescript
import { createAdapterFromPrivateKey } from "@circle-fin/adapter-viem-v2";
import { createPublicClient, http } from "viem";

// Create an adapter
const adapter = createAdapterFromPrivateKey({
  privateKey: process.env.PRIVATE_KEY as string,
  // Replace the default connection
  getPublicClient: ({ chain }) =>
    createPublicClient({
      chain,
      // Use an Alchemy connection
      transport: http(
        `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY}`,
        {
          retryCount: 3,
          timeout: 10000,
        },
      ),
    }),
});

You can create an adapter from browser wallet apps like MetaMask or Phantom.

The following code creates an adapter from a MetaMask wallet. Pick your adapter to see the code.

  • Viem
  • Ethers
  • Solana
Typescript
import { createAdapterFromProvider } from "@circle-fin/adapter-viem-v2";
import { MetaMaskInpageProvider } from "@metamask/providers";
import { EIP1193Provider } from "viem";

declare global {
  interface Window {
    ethereum?: MetaMaskInpageProvider;
  }
}

const adapter = createAdapterFromProvider({
  provider: window.ethereum as EIP1193Provider,
});
Did this page help you?
© 2023-2025 Circle Technology Services, LLC. All rights reserved.