Skip to main content
App Kit works with common adapter libraries to integrate smoothly with your existing workflow:
  • viem v2 for EVM-compatible blockchains
  • ethers v6 for EVM-compatible blockchains
  • solana for the Solana blockchain
  • circle-wallets for your existing Circle Wallets account
Pick your adapter to see its setup options.

Standard setup

The standard setup is the fastest way to start. Create one adapter from your wallet private key that works across multiple blockchains.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.
TypeScript
import { createViemAdapterFromPrivateKey } from "@circle-fin/adapter-viem-v2";

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

Custom RPC

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.To use your own connection, replace the default one and add your custom RPC endpoints. Map each chain to its RPC endpoint so one adapter can work across multiple chains. This example uses Alchemy connections:
TypeScript
import { createViemAdapterFromPrivateKey } from "@circle-fin/adapter-viem-v2";
import { EthereumSepolia, ArcTestnet } from "@circle-fin/app-kit/chains";
import { createPublicClient, http } from "viem";

// Map RPC endpoints by chain name
const RPC_BY_CHAIN_NAME: Record<string, string> = {
  [EthereumSepolia.name]: `https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`,
  [ArcTestnet.name]: `https://arc-testnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`,
};

// Create an adapter
const adapter = createViemAdapterFromPrivateKey({
  privateKey: process.env.PRIVATE_KEY as string,
  // Replace the default connection
  getPublicClient: ({ chain }) => {
    const rpcUrl = RPC_BY_CHAIN_NAME[chain.name];
    if (!rpcUrl) {
      throw new Error(`No RPC configured for chain: ${chain.name}`);
    }
    return createPublicClient({
      chain,
      transport: http(rpcUrl, {
        retryCount: 3,
        timeout: 10000,
      }),
    });
  },
});

Browser wallet

You can create an adapter from browser wallet apps like MetaMask or Phantom:
TypeScript
import { createViemAdapterFromProvider } from "@circle-fin/adapter-viem-v2";
import type { EIP1193Provider } from "viem";

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

// Check if wallet provider is available
if (!window.ethereum) {
  throw new Error("No wallet provider found");
}

const adapter = await createViemAdapterFromProvider({
  provider: window.ethereum,
});