Use launchToken from @clanktrade/sdk to create the ERC-20 launch token and
its bonding curve. The function reads the current factory configuration,
predicts the launch addresses, simulates the transaction, and returns one
unsigned instruction for your wallet.
pnpm add @clanktrade/sdk viembun add @clanktrade/sdk viemnpm i @clanktrade/sdk viemyarn add @clanktrade/sdk viemThis guide assumes your app already has a Robinhood Chain publicClient and a
connected walletClient.
The launch-only and atomic-buy snippets below are alternatives. Choose one for each token; do not submit both.
Define the launch
import { launchToken } from "@clanktrade/sdk";
import { zeroAddress, type Address } from "viem";
const [creator] = await walletClient.getAddresses();
if (!creator) throw new Error("Connect a wallet before launching");
const launchDetails = {
publicClient,
creator,
name: "Example Token",
symbol: "EXAMPLE",
logo: "https://example.com/token.png",
} as const;The SDK checks that the public client is on a supported Robinhood network and validates metadata before making contract calls. Keep the connected wallet on the same network when you submit the returned instruction.
| Field | Requirement |
|---|---|
name |
1–64 UTF-8 bytes |
symbol |
1–16 UTF-8 bytes |
logo |
1–256 UTF-8 bytes |
description |
Up to 1,024 bytes |
| Social links | Up to 256 bytes |
Launch without an opening buy
Call launchToken with the required details. Optional metadata and launch
settings belong in the second argument.
const launch = await launchToken(launchDetails, {
description: "An example token launched with Clank.",
socials: {
website: "https://example.com",
twitter: "https://x.com/example",
},
pairToken: zeroAddress,
});
console.log({
launchToken: launch.token,
curve: launch.curve,
pairToken: launch.pairToken,
});The zero address selects native ETH as the curve’s quote token. To launch
against another approved quote token, pass its address as pairToken. A
launch-only transaction does not spend the quote token, so it needs no ERC-20
approval.
Launch and buy atomically with ETH
Set initialBuyEth to include an opening buy in the same transaction as the
launch.
import { parseEther } from "viem";
const openingBuyOptions = {
description: "An example token launched with Clank.",
pairToken: zeroAddress,
initialBuyEth: parseEther("0.1"),
slippageBps: 100,
} as const;
const launch = await launchToken(launchDetails, openingBuyOptions);
if (!launch.initialBuy) throw new Error("Opening buy was not prepared");
console.log({
launchToken: launch.token,
curve: launch.curve,
ethIn: launch.initialBuy.ethIn,
expectedTokens: launch.initialBuy.amountOut,
minimumTokens: launch.initialBuy.minimumAmountOut,
route: launch.initialBuy.route.label,
});slippageBps: 100 allows 1% slippage. The SDK simulates the complete launch
and opening buy to calculate amountOut, then encodes
minimumAmountOut into the returned transaction.
Use an ERC-20 quote token
The opening buy is still funded with ETH when the curve uses an ERC-20 quote
token. Pass the approved quote-token address and the same initialBuyEth
option:
const pairToken = "0x..." as Address;
const launch = await launchToken(launchDetails, {
pairToken,
initialBuyEth: parseEther("0.1"),
slippageBps: 100,
});The SDK finds an ETH-to-quote-token route and encodes the swap, launch, and first curve buy into one atomic instruction. The creator does not need to hold or approve the ERC-20 quote token. If the route or any later step fails, the whole transaction reverts.
Submit the instruction
launchToken never opens a wallet or broadcasts a transaction. Submit its
instruction with the same creator account used to build it:
const hash = await walletClient.sendTransaction({
account: creator,
to: launch.instruction.to,
data: launch.instruction.data,
value: launch.instruction.value ?? 0n,
});
const receipt = await publicClient.waitForTransactionReceipt({ hash });
if (receipt.status !== "success") {
throw new Error(`${launch.instruction.label} reverted`);
}For launch-only, the instruction targets the canonical factory. For an atomic
opening buy, it targets the factory’s current launch forwarder and includes the
launch fee plus initialBuyEth as its value.
Verify the launch
After confirmation, create a trading client for the predicted token. This checks that the canonical factory registered the launch and resolves its curve and quote token.
import { createClankClient } from "@clanktrade/sdk";
const clank = await createClankClient({
publicClient,
launchToken: launch.token,
});
if (clank.pairToken.toLowerCase() !== launch.pairToken.toLowerCase()) {
throw new Error("Factory returned a different quote token");
}From here, use Trade on the bonding curve to quote and execute later buys or sells.
Options
The first argument contains the required launch fields:
| Name | Type | Description |
|---|---|---|
publicClient |
PublicClient |
Viem client connected to Robinhood Chain. |
creator |
Address |
Sends the transaction and creates the token. |
name |
string |
Launch-token name. |
symbol |
string |
Launch-token symbol. |
logo |
string |
Public image URL. |
The second argument is optional:
| Name | Type | Default | Description |
|---|---|---|---|
description |
string |
"" |
Token description. |
socials |
Partial<ClankSocials> |
Empty values | Twitter, Telegram, Discord, website, and Farcaster links. |
pairToken |
Address |
Zero address | Approved curve quote token; zero address means native ETH. |
initialBuyEth |
bigint |
0n |
ETH opening-buy amount in wei. |
slippageBps |
number |
100 |
Opening-buy slippage in basis points. |
recipient |
Address |
Creator | Receives tokens from the opening buy. |
creatorFeeRecipient |
Address |
Creator | Receives the creator share of curve fees. |
snipeTaxExemptions |
readonly Address[] |
[] |
Additional accounts exempt from launch-window snipe tax. |
salt |
Hex |
Random | CREATE2 entropy used to derive the token and curve. |
launchConfigId |
bigint |
0n |
Factory launch configuration. |
deadline |
bigint |
Latest + 5 min | Route deadline for an ERC-20-paired opening buy. |
The factory currently requires a zero creator tax and disables buybacks; the SDK supplies those values automatically. It also reads and pins the current launch economics so a configuration change makes the transaction revert instead of silently changing its terms.
Retry and refresh safely
The default salt is random. Save and reuse launch.salt if you need to rebuild
the same launch after a rejected wallet request:
const refreshed = await launchToken(launchDetails, {
...openingBuyOptions,
salt: launch.salt,
});Reuse every launch option along with the salt to preserve the predicted addresses. Request a fresh launch plan whenever the account, chain, pair token, metadata, opening-buy amount, or slippage changes. If the original transaction was confirmed, the SDK reports that the salt is already in use instead of returning an opaque CREATE2 error.
Common failures
| Message or error | What to check |
|---|---|
Clank trading requires Robinhood chain |
Connect the public client and wallet to Robinhood Chain. |
PairTokenNotApproved |
Use native ETH or a quote token approved by the factory. |
The factory has no launch-and-buy forwarder |
Retry after launch-and-buy is configured, or launch without one. |
Initial buy is too small |
Increase initialBuyEth. |
A launch with this salt already exists |
Use a new salt unless the existing launch is the intended one. |
OutputBelowMinimum |
Refresh the quote or increase slippageBps. |
At creation, the curve receives the full launch-token supply. An atomic opening
buy immediately transfers its purchased tokens to recipient. See
Token lifecycle for how the remaining curve supply
progresses into permanently locked Uniswap V4 liquidity.