Skip to main content

SDK reference

This page lists the public surface of @bankr/launch-sdk: the client, its methods, each namespace, what the calls return, the helpers and the constants.

Fee rates are in pips: 10,000 pips is 1%. Shares are in bps: 100 bps is 1%. Amounts are bigint values in a token's base units.

Entry points​

ImportRuns inWhat it exports
@bankr/launch-sdkBrowsers and serverscreateLaunchClient, createBankrApi, remoteAuthorizer, the helpers, the constants and the errors
@bankr/launch-sdk/serverServers onlyEverything in the root entry, plus the helpers that hold your launchpad's signing key: createAuthorizeHandler, padAuthorizer, signLaunchAuthorization

createLaunchClient(options)​

// client.ts
import { createLaunchClient } from "@bankr/launch-sdk";

export const client = createLaunchClient({
chain: "base", // required
rpcUrl: process.env.BASE_RPC_URL,
});

A client reads without a wallet. It needs a walletClient only for client.launch. The client's options lists every option.

Launching​

MethodWhat it does
plan(input)Checks a launch against its launchpad, resolves the terms the coin would get, predicts the token and simulates. Sends nothing.
launch(input)Plans, sends any approval, simulates, sends the launch from the wallet and reads the receipt. Plans again when the terms move under it.
buildLaunchTx(plan, { gas? })The unsigned launch transaction, for wagmi, a Safe or a bundler.
simulate(plan)Simulates the plan from the launcher.
parseLaunchReceipt(receipt, expectedToken?)The launch in a mined receipt.
previewExtension(extension, { launchpadId })What an extension does and whether it can launch on a launchpad now. Reads only.
status(){ paused, gated }, read live from the chain.
chain, provider, publicClientThe chain's facts, the contract addresses (client.provider.addresses) and the read client.

What client.plan returns​

FieldMeaning
predictedToken, poolIdThe coin's address and its pool's id, for this plan.
volumeSplitHow each trading fee splits, in pips of the trade: Bankr, holders, payees, auto-LP, buyback, creator.
extensionThe extension as the pool will hold it, with what a confirm screen shows. null with none.
distributor, escrowThe coin's holder-rewards contract, and its vesting escrow or null when nothing vests.
approvalsFor a first buy paid in an ERC-20: the approval to send before the launch.
value, devBuyOutThe ETH the launch sends for a first buy, and the tokens the first buy would receive.
gasEstimateFrom a simulation. null when the RPC could not estimate.
resolved.termsEvery term the coin will carry, as the contracts resolved it.
resolved.resolvedHashThe hash of those terms. The launch reverts where other terms are in force when it lands.

A plan goes stale: its start price follows the quote token's price, and any approval by a launchpad's signer expires. client.launch makes its own plan with a fresh salt, so its token differs from an earlier plan's predictedToken.

What client.launch returns​

client.parseLaunchReceipt(receipt) returns the same.

FieldMeaning
token, poolId, txHashThe coin, its pool and the launch transaction.
launcher, launchpadId, quoteWho launched, on which launchpad, against which quote token.
feeRecipientsThe fee recipients, each with its share.
metadataUri, metadataAdminThe metadata link, and who may replace it or null.
tradingStartThe scheduled start in Unix seconds, or null when trading opened at once.
curve, startTick, totalSupplyThe launch's curve, its start tick and the supply.
distributor, escrowThe coin's holder-rewards contract and its vesting escrow.
vestingRecipient, vestBpsThe creator's vest.
devBuyOutThe tokens the first buy received.

UnsignedTx​

{ chainId, from, to, data, value, gas? }. from is the account that must send it. Send it with viem, wagmi, a Safe or a bundler.

After launch​

Reads need no wallet. Every build… call returns an unsigned transaction, or a list of them, and sends nothing.

MethodWhat it does
launchInfo(token)A coin as the chain holds it: launchpad, launcher, fees, fee recipients, trading start, curve. null for a token these contracts did not launch.
tradingStatus(token)Whether a coin trades yet: { started, startTime, secondsUntilStart }.
verifyTokenInvariants(token, receipt?)Holds a token to what every launch guarantees: { ok, failures, skipped }.

client.fees​

Guide: Fees and rewards.

MethodWhat it does
get(token, account?)An account's share of one coin's fees, and what it can claim now.
buildClaim(token, account, { side? })Claims one coin's fees for the account.
getOwed(account)Everything an account is owed on the chain.
buildClaimAll(account, options?)Claims all of it: { txs, plan }. Send txs in order.
getBalances(account, quotes?)The account's settled balance per quote token.
buildWithdraw(account, quotes, bucketIds?)Pays that balance out.
buildSetFeeRecipient(token, account, newRecipient)Moves the account's own fee share to another wallet.
getClaimPolicy(account, caller?)Whether the account restricts who may claim for it.
buildSetClaimRestricted(account, restricted)Restricts claims to the account and the wallets it names, or opens them again.
buildSetClaimOperator(account, operator, allowed)Names a wallet that may claim for the account.

client.holders​

Guide: Holder rewards.

MethodWhat it does
get(token, account)What a holder has earned on one coin, per reward: legs.bnkr, legs.quote, legs.token.
buildClaim(token, account, { leg?, gas? })Claims a holder's rewards on one coin.
buildClaimAll(account, tokens, options?)Claims several coins together.
buildClaimFor(token, sender, accounts)Pays the gas for other holders' claims. Each holder is paid its own rewards.
getConversion(token)The holders' share waiting to convert to BNKR, and whether it is due.
buildConvert(token, sender)Converts it. Anyone may send it.

client.vesting​

MethodWhat it does
get(token)The coin's vesting escrow and every schedule, with what is releasable now.
buildRelease(token, account)Releases everything that has unlocked for the account.
buildReleaseToHolders(token, account)Pushes the holders' vested slice to the coin's holders. Anyone may send it.

client.metadataAdmin​

MethodWhat it does
get(token)The metadata link, its admin and any pending handover.
buildSetUri(token, account, uri)Replaces the link. Sent by the admin.
buildTransfer(token, account, to)Offers the role to to. null withdraws an offer.
buildAccept(token, account)Takes the role that was offered.
buildRenounce(token, account)Fixes the link for good.

Launchpads and settings​

client.contracts() returns the namespaces that read and change launchpads:

const { settings, launchpads, coinTerms, holderLegs } = client.contracts();

launchpads​

A launchpad operator's transactions. Guide: Set up a launchpad.

MethodWhat it builds
register({ operator, payees, signer?, metadataUri? })A new launchpad. Its value is the bond.
launchpadIdFromReceipt(receipt)The id in a mined registration. Not a transaction.
configure(id, { knobs?, switches?, capController?, payees?, decayAutoLpBps?, presets? })Any of them in one transaction.
setKnobs(id, knobs)Each named knob's min, max or default.
setSwitches(id, switches)Features on or off. The ones not named stay as they are.
setTakeover(id, on)The takeover switch alone.
setPayees(id, payees, { decayAutoLpBps? })Replaces the payees and the snipe-fee split together.
setCapController(id, account | null)Who may end a wallet cap early on the launchpad's future coins.
setQuoteTerms(id, quote, { allowed?, ownAmounts?, compoundFloor?, compoundCap? })The launchpad's own word on a quote token.
setCurveAllowed(id, curve, allowed)Allows or refuses a built-in curve, one set of bands, or "any" bands. isCurveAllowed(id, curve) reads.
setPresetLimits(id, preset, { allowed?, maxWindowSecs?, minBrakeTicks?, minAnchorTau? })One built-in extension's limits: "sniperTax", "decayTax", "pumpBrake" or "raffleRun".
setSigner(id, signer | null)The launchpad's signer. null makes it open.
setVanity(id, { suffix, nibbles })The address suffix. nibbles: 0 removes it.
setMetadataUri(id, uri), setPaused(id, paused)The branding link, and the launchpad's own pause.
transferOperator(id, next), acceptOperator(id)A two-step handover.

A broken rule throws INVALID_LAUNCHPAD_CONFIG, and err.detail says which. An id no launchpad holds throws UNKNOWN_LAUNCHPAD.

settings​

Reads of what the contracts and each launchpad hold a launch to.

MethodReturns
pad(id)One launchpad: atLaunch (the ranges, defaults and switches a launch meets now), payees, decay, operator, signer, paused, vanity.
limits()The widest range a launchpad can set for each knob: { min, max } by knob name.
template()What a new launchpad starts with: knobs, switches, capController, presets.
allowedSwitches()The switches a launchpad may use.
protocol()Bankr's cut of each fee and of an extension's fee, the takeover notice, the most payees a launchpad may name.
quotes(), quote(address)The quote tokens Bankr lists, and one token's row.
padQuote(id, quote)A launchpad's own word on a quote token, and launches: whether a launch on it may pair with that token.
presets()The built-in extensions' records.
extensionAllowed(key)Whether the extension allowlist holds a key. extensionAllowlistKey builds the key.
levers()Chain-wide facts: paused, registrationBondWei, owner, treasury, hook, holderLeg.
preview(params, { launcher })The contracts' launch check as a read. client.plan calls it for you.

coinTerms​

A coin's terms as they were fixed at launch. Guide: What is fixed at launch.

MethodReturns
fromReceipt(receipt, token?)The record in a launch receipt: { token, poolId, termsHash, resolvedHash, terms }. No RPC call.
frozen(token)The same record, read from the chain. null for a token these contracts did not launch.
verify(token, record){ ok, hashMatches, storesMatch }: the record is the coin's, and the coin still is what it says.

holderLegs​

The conversion contract: the contract that converts the holders' share to BNKR.

MethodReturns
current()The conversion contract new launches use: what it pays in, and its route to BNKR for each quote token.
ofCoin(token)The conversion contract a coin uses, fixed for life.
pile(token)The holders' share waiting to convert for a coin: pile, floor, converts, due.

createBankrApi(options?)​

Bankr's public API without a launch client: no RPC, no wallet and no key. options is { url?, fetch? }. Guide: Reading launches.

MethodWhat it does
launches(query)One page of launches: { launches, nextCursor }, with incomplete when a chain's launches are left out.
allLaunches(query, { max?, signal?, onIncomplete? })Every launch matching query, a page at a time, for for await. Throws INDEX_UNAVAILABLE on an incomplete page unless you pass onIncomplete.
launch(chain, token, query?)One launch, or null when Bankr has not indexed it.
launchpadStats(chain, id, query?)One launchpad's launch count and 24-hour volume.
builder(slug, query?)A builder's profile and stats, or null for an unknown slug.
register(chain, txHash)Indexes a launch transaction once it has 5 confirmations.
accountFees(chain, account, ledger?)What an account is owed on the chain's fee ledger.

client.index has the first six on the client's own chain: launches, all, launch, launchpadStats, builder and register.

Server helpers​

For a launchpad with a signer. Guide: Launch for your users.

ExportEntryWhat it does
remoteAuthorizer(url, init?)rootAn authorizer for the browser. It posts each launch's terms to your launchpad's signing route.
createAuthorizeHandler(options)serverA route for remoteAuthorizer: { account, chain, launchpadId, authorize, registry?, deadlineSeconds?, onError? }.
padAuthorizer({ account, authorize? })serverAn authorizer for a client that runs on your own server.
signLaunchAuthorization(input)serverSigns one launch's exact terms with the launchpad's signer (EIP-712).

createAuthorizeHandler's authorize has no default allow. Throw from it to refuse. A signature lasts 600 seconds unless you set deadlineSeconds.

Unit helpers​

HelperSignatureExample
percentToPips(percent: string | number) => numberpercentToPips("1.75") is 17500
pipsToPercent(pips: number | bigint) => stringpipsToPercent(4_750) is "0.475"
percentToBps(percent: string | number) => numberpercentToBps("50") is 5000
bpsToPercent(bps: number | bigint) => stringbpsToPercent(875) is "8.75"

All four throw INVALID_PERCENT on a negative value or one above 100%. Pass percentages as strings: a computed number such as 0.1 + 0.2 is refused.

Swap helpers​

For a router or wallet that builds its own swaps through Bankr pools. Add swapGasHeadroom(pool) to the swap's simulated gas limit for each Bankr pool on the route.

HelperSignatureWhat it does
swapGasHeadroom(pool: { extHeadroom: bigint }) => bigintThe gas to add for one Bankr pool: 960,000 plus extHeadroom.
readExtSwapGasHeadroom(client, { hook, poolId }) => Promise<bigint>The pool's extHeadroom, read from the hook. 0n for a pool with no extension.
encodeHookData({ referrer?, holdersWake?, routeCurrencies?, extData? }) => HexA swap's hook data for one Bankr pool. "0x" with nothing set.
holdersWakeRequest(route, index) => { keepGas } | nullThe request a Bankr pool on a route carries to ask for the holders' conversion.
holdersWakeSwapGas(keepGas: number) => bigintThe gas to add so the swap runs the conversion.

A swap that asks for the holders' conversion pays holders as the coin trades. Give every Bankr pool on the route its own request, and add the conversion's gas when it is due. route holds one { extHeadroom } per Bankr pool on the route, in order.

import {
encodeHookData,
holdersWakeRequest,
holdersWakeSwapGas,
readExtSwapGasHeadroom,
swapGasHeadroom,
} from "@bankr/launch-sdk";
import type { Address, Hex } from "viem";

/** The hook data and the extra gas for a one-pool swap of `token`. `poolId` is the coin's pool id. */
export async function swapExtras(token: Address, poolId: Hex) {
const extHeadroom = await readExtSwapGasHeadroom(client.publicClient, {
hook: client.provider.addresses.hook,
poolId,
});
const request = holdersWakeRequest([{ extHeadroom }], 0);
const hookData = encodeHookData({ holdersWake: request });

let extraGas = swapGasHeadroom({ extHeadroom });
const { due } = await client.holders.getConversion(token);
if (due && request) extraGas += holdersWakeSwapGas(request.keepGas);
return { hookData, extraGas };
}

Asking costs nothing when no conversion is due. A conversion that is short of gas is skipped, and the swap still lands.

Curve helpers​

HelperWhat it does
curveFromMarketCapsTurns market-cap ranges into bands.
curveMarketCapsTurns bands back into market-cap ranges, for a chart.
checkCurveHolds bands to a coin's curve rules without a client. Pass them as rules, from plan.resolved.terms.curve.
encodeCurve, decodeCurvePacks bands into the one word a launch carries, and unpacks it.
startTickForQuoteFdvThe start tick for a start value in the quote token's base units, as startFdv uses it.
BUILT_IN_CURVESThe built-in curves' exact bands.

More helpers​

ExportUse it to
CHAINS, LAUNCH_CHAINS, getChain, isLaunchChainRead a chain's facts: its id, its named quote tokens and its gas ceiling.
mineVanitySalt, randomSalt, predictTokenSearch for a salt for a long address suffix, and predict a token's address.
launchGasFallback, clampLaunchGasSize a launch's gas limit when you send it yourself and your RPC gives no estimate.
buildCallTx, buildApproveTxWrap your own calldata, or an ERC-20 approval, as an UnsignedTx.
launchAuthorizationTypedData, launchTermsHashBuild the EIP-712 data your launchpad's signer signs, for a signing service of your own.
extensionFeeTable, describePreset, encodeExtensionPresetParamsDraw an extension's fee over time, describe a built-in extension, and encode its parameters.
planClaimAllPlan a claim of many fee shares within a gas limit, from amounts you already hold.
bankrLaunchSettingsAbi, bankrLaunchpadRegistryAbi, bankrTermsLensAbiRead the contracts with viem directly.

Constants​

ConstantValueMeaning
KNOB_NAMES, SWITCH_NAMES38 knobs, 11 switchesEvery launchpad setting's name.
PRESET_NAMESsniperTax, decayTax, pumpBrake, raffleRunThe built-in extensions as a launchpad's settings name them.
EXTENSION_PRESETSsniper_tax, decay_tax, pump_brake, raffle_runThe built-in extensions as a launch names them, each with its id.
PIPS1,000,000100% in pips.
CURVE_NAMES, CURVE_MAX_BANDS["runner_v1", "degen", "thin_topside"], 8The built-in curves, and the most bands a curve has.
BANKR_LAUNCHPAD_ID0nBankr's own launchpad.
SWAP_GAS_HEADROOM960_000nGas to add to a swap per Bankr pool on its route.
EXT_QUOTE_GAS, EXT_QUOTE_GAS_MAX, EXT_AFTER_GAS, EXT_AFTER_GAS_MAX50,000, 250,000, 150,000, 1,000,000The range of a custom extension's two gas budgets.
LAUNCH_ALLOCATION_GAS129_400nWhat one allocation adds to a launch's gas.
REGISTER_MIN_CONFIRMATIONS, DEFAULT_BANKR_API_URL5, "https://api.bankr.bot"Confirmations before the launch index registers a launch, and Bankr's API.
LAUNCH_SDK_ERROR_CODESEvery codeErrors

Errors​

Every refusal is a LaunchSdkError with a stable code. isLaunchSdkError(err, code?) narrows it, and launchRevertName(err.cause) names a contract revert. Errors lists every code.