Skip to content

Quickstart

Install the Clank SDK and execute your first trade.

Updated View as Markdown

Install the SDK

Install the Clank SDK and Viem:

pnpm add @clanktrade/sdk viem

Prerequisites

This example assumes your app already has:

  • a Viem publicClient connected to Robinhood Chain
  • a Viem walletClient connected to the trader’s wallet
  • the Clank launch-token address you want to trade

Quote and execute a buy

The SDK resolves the launch through the canonical factory and selects its current venue. The same code works while the token is on its bonding curve and after it graduates to Uniswap V4.

buy-clank-token.tsts
import { createClankClient } from "@clanktrade/sdk";
import { parseEther, type Address } from "viem";

const launchToken = "0x..." as Address;
const [trader] = await walletClient.getAddresses();
if (!trader) throw new Error("Connect a wallet before trading");

const clank = await createClankClient({ publicClient, launchToken });
const quote = await clank.quoteBuy({
  ethIn: parseEther("0.0001"),
  trader,
  slippageBps: 100,
});

// Display quote.amountOut and quote.minimumAmountOut before continuing.
const instructions = await clank.buildBuy({ quote, trader });

for (const instruction of instructions) {
  const hash = await walletClient.sendTransaction({
    account: trader,
    to: instruction.to,
    data: instruction.data,
    value: instruction.value ?? 0n,
  });
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
  if (receipt.status !== "success")
    throw new Error(`${instruction.label} reverted`);
}

quoteBuy only reads and simulates; it does not open the wallet. buildBuy returns unsigned approval and trade instructions in submission order. Wait for each successful receipt before sending the next instruction.

Next, see Trade on the bonding curve, Trade after graduation, or the complete SDK API reference.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close