React Hooks

LaunchRobin provides React hooks for Next.js apps, wrapping LaunchpadSDK with state management, loading states, and error handling.

WalletProvider & Context Hooks

Wrap your app with WalletProvider to enable wallet connection, chain selection, and SDK access.

// app/layout.tsx
import { WalletProvider } from "./components/WalletContext";

export default function RootLayout({ children }) {
  return <WalletProvider>{children}</WalletProvider>;
}

useWalletConnection()

const { isConnected, address, balance, signer, connect, disconnect }
  = useWalletConnection();
FieldTypeDescription
isConnectedbooleanWallet is connected
addressstringConnected wallet address
balancestringETH balance (formatted)
signerSigner | nullEthers signer for transactions
connect()() => Promise<void>Request wallet connection
disconnect()() => voidDisconnect wallet

useChain()

const { selectedChainId, setSelectedChainId } = useChain();

useSDK()

const { sdk } = useSDK();
// sdk: LaunchpadSDK | null
// Recreated whenever chain or signer changes

useTerminalLog()

const { logs, logMessage, clearLogs } = useTerminalLog();
logMessage("Token created!", "success");

useTokenLaunches(sdk)

Fetches all token launches from the on-chain registry and maps to UI rows. Returns loading state, error state, and a refresh function.

const { launches, trending, isLoading, error, refresh }
  = useTokenLaunches(sdk);

// launches: TokenListRow[] — mapped for table display
// trending: TrendingCarouselToken[] — top 5 by fill %
// refresh(): void — re-fetch with loading state

Each TokenListRow includes: name, ticker, market cap (USD), volume (USD), hold count, age string, fill percent, artwork.

useTokenDetails(sdk, tokenAddress)

Fetches full token details and trade history for the detail page.

const {
  tokenDetails,
  tradeHistory,
  progressPercent,
  isLoading,
  error
} = useTokenDetails(sdk, "0x...");

useTradeQuote(sdk, tokenAddress, mode, amount)

Debounced quote engine. Returns estimated output and fee for a given swap amount. Debounces by 400ms to avoid excessive RPC calls.

const {
  estimatedOutput,  // string — tokens for buy, ETH for sell
  estimatedFee,     // string — fee in ETH
  isQuoting,        // boolean — currently fetching
  error             // string | null
} = useTradeQuote(sdk, tokenAddress, "buy", "0.1");

useSwapExecution(sdk)

Executes buy/sell transactions with slippage protection and terminal logging.

const {
  executeBuy,     // (token, ethAmount, minTokensOut, slippage) => Promise<string|null>
  executeSell,    // (token, tokenAmount, minEthOut, slippage) => Promise<string|null>
  isBusy,         // boolean
  error,          // string | null
  clearError      // () => void
} = useSwapExecution(sdk);