Setup Flow

This guide walks through the complete user onboarding flow, from wallet connection to making the first authenticated API call.

Overview

spinner

Phase 1: Connect Wallet

The user connects their EOA wallet (MetaMask, WalletConnect, etc.) to the application.

// Using Wagmi + ConnectKit in React
import { ConnectKitButton } from "connectkit";
import { useAccount, useWalletClient } from "wagmi";

function App() {
  const { address, isConnected } = useAccount();
  const { data: walletClient } = useWalletClient();

  return (
    <div>
      <ConnectKitButton />
      {isConnected && <p>Connected: {address}</p>}
    </div>
  );
}

Phase 2: Initialize SDK and Deploy Smart Account

Phase 3: Create and Approve Session Key

spinner

Phase 4: Authorize with Server

Send the session key data to the Router402 server to receive a JWT token.

Phase 5: Make Authenticated API Calls

Use the JWT token for chat completions.

Using setupAccount (Simplified)

The SDK provides setupAccount() to handle phases 2-3 in a single call:

Error Handling

Last updated