> ## Documentation Index
> Fetch the complete documentation index at: https://pons-labs-llc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Launching

> Launch a v2 token from code: launch configs, pinned terms, CREATE2 addresses, snipe-tax exemptions, and launching with an opening buy.

A launch is one call to the [factory](https://pons-labs-llc.mintlify.site/developers/contracts.md#v2). You pick a
launch config and a quote asset, and send the launch fee as value. For a guided
walkthrough of the same call, see
[launching from the factory](https://pons-labs-llc.mintlify.site/developers/launch-from-factory.md).

Anyone can launch today. `canLaunch(address)` answers whether a wallet may, in
one call.

## Launch configs

Configs live in an append-only list, so an id never changes meaning. The owner
can edit or disable one, and a disabled config reverts with
`LaunchConfigDisabled`, so read the list when you build the form rather than
caching ids. There is one config today, id `0`.

```ts theme={null}
const factoryAbi = parseAbi([
  "struct LaunchConfig { uint256 supply; uint256 curveFeeBps; uint256 phantomQuote; uint256 graduationThreshold; uint24 poolFee; int24 tickSpacing; bool enabled; }",
  "function launchConfigCount() view returns (uint256)",
  "function getLaunchConfig(uint256 id) view returns (LaunchConfig)",
]);

async function openLaunchConfigs() {
  const count = await client.readContract({
    address: factory,
    abi: factoryAbi,
    functionName: "launchConfigCount",
  });
  const configs = await Promise.all(
    Array.from({ length: Number(count) }, (_, id) =>
      client.readContract({
        address: factory,
        abi: factoryAbi,
        functionName: "getLaunchConfig",
        args: [BigInt(id)],
      }),
    ),
  );
  return configs
    .map((config, id) => ({ id: BigInt(id), ...config }))
    .filter((config) => config.enabled);
}
```

## Launching with pinned terms

Read `previewLaunchEconomics` right before launching and pass the result as
`expectedEconomics`. If the owner changes the config in between, the launch
reverts with `LaunchEconomicsMismatch` instead of settling on terms you did not
read.

```ts theme={null}
import { parseAbi, toHex } from "viem";

const factoryAbi = parseAbi([
  "struct Socials { string twitter; string telegram; string discord; string website; string farcaster; }",
  "struct TokenParams { string name; string symbol; string logo; string description; Socials socials; address creatorFeeRecipient; uint16 creatorTaxBps; bool buybackEnabled; bytes32 expectedEconomics; bytes32 salt; }",
  "function launchToken(TokenParams params, uint256 launchConfigId, address pairToken) payable returns (address token, address curve)",
  "function previewLaunchEconomics(uint256 launchConfigId, address pairToken) view returns (bytes32)",
  "function launchFee() view returns (uint256)",
]);

const launchConfigId = 0n;
const pairToken = "0x0000000000000000000000000000000000000000"; // native ETH

// Any salt you have not used before. See "Launch addresses" below.
const salt = toHex(crypto.getRandomValues(new Uint8Array(32)));

const [expectedEconomics, launchFee] = await Promise.all([
  client.readContract({ address: factory, abi: factoryAbi, functionName: "previewLaunchEconomics", args: [launchConfigId, pairToken] }),
  client.readContract({ address: factory, abi: factoryAbi, functionName: "launchFee" }),
]);

const hash = await wallet.writeContract({
  address: factory,
  abi: factoryAbi,
  functionName: "launchToken",
  args: [
    {
      name: "Example",
      symbol: "EXMPL",
      logo: "https://...",
      description: "An example launch.",
      socials: { twitter: "", telegram: "", discord: "", website: "", farcaster: "" },
      creatorFeeRecipient: creator, // zero defaults to the caller
      creatorTaxBps: 0,             // up to maxCreatorTaxBps(), 1000 today
      buybackEnabled: true,
      expectedEconomics,
      salt,
    },
    launchConfigId,
    pairToken,
  ],
  value: launchFee, // 0.0005 ETH today
});
```

| Field | Limit |
| - | - |
| `name` | 64 bytes |
| `symbol` | 16 bytes |
| `logo` | 512 bytes |
| `description` | 2,048 bytes |
| each social | 256 bytes |
| `creatorTaxBps` | `maxCreatorTaxBps()`, 1000 (10%) |

Past a metadata limit the launch reverts with `MetadataTooLong`.

## Launch addresses

The launch deployer derives the curve and token through CREATE2 from your
`salt`, the wallet that started the transaction, and the launch's own terms. So
both addresses are known before you send, and nobody else can take them by
sending your salt first. Reusing a salt on identical terms reverts.

To mine a vanity address, search salts offline and confirm with
`predictLaunchAddresses` on the launch deployer. It takes the full launch
deployment struct and returns `(token, curve)`.

## Exempting wallets from the opening tax

An overload adds a final `address[]` of wallets exempt from the
[snipe tax](https://pons-labs-llc.mintlify.site/protocol/snipe-protection.md). At most 32 entries, past which it
reverts with `ExemptionListTooLong`. The list is fixed at creation. The launching
wallet and the creator fee recipient are always exempt.

```ts theme={null}
"function launchToken(TokenParams params, uint256 launchConfigId, address pairToken, address[] snipeTaxExemptions) payable returns (address token, address curve)"
```

## Launching and buying in one transaction

A launch followed by a separate buy leaves a gap anyone can trade in first. The
launch-and-buy router does both in one call. It holds callers to the factory's
launch gate (`NotApprovedLauncher` otherwise) and records the launch under the
wallet that started the transaction.

* `creatorFeeRecipient` must be set. Zero reverts with `ZeroAddress`.
* The buy's `recipient` is exempted for you, so at most 31 extra exemptions.
* `minTokensOut` still applies if the curve fills only part of the buy.
* The value must be exactly the fee plus `quoteIn` on an ETH launch, or just the
  fee on an ERC-20 launch, else `NativeValueMismatch(sent, expected)`.

```ts theme={null}
const routerAbi = parseAbi([
  "struct Socials { string twitter; string telegram; string discord; string website; string farcaster; }",
  "struct TokenParams { string name; string symbol; string logo; string description; Socials socials; address creatorFeeRecipient; uint16 creatorTaxBps; bool buybackEnabled; bytes32 expectedEconomics; bytes32 salt; }",
  "function launchAndBuy(TokenParams params, uint256 launchConfigId, address pairToken, uint256 quoteIn, uint256 minTokensOut, address recipient, address[] snipeTaxExemptions) payable returns (address token, address curve, uint256 tokensOut)",
]);

// ERC-20 pair: approve the router for quoteIn first.
const hash = await wallet.writeContract({
  address: launchAndBuy,
  abi: routerAbi,
  functionName: "launchAndBuy",
  args: [params, launchConfigId, pairToken, quoteIn, minTokensOut, recipient, []],
  value: pairToken === zeroAddress ? launchFee + quoteIn : launchFee,
});
```

## Quote assets

Pass the zero address for ETH, or an approved ERC-20. Approval is set by the
owner; an unapproved asset reverts with `PairTokenNotApproved`. 71 assets are
approved today, including USDG and tokenized stocks.

Each asset carries its own economics, sized in its own decimals. Only offer an
asset that passes both reads below, and format amounts with its decimals rather
than 18.

```ts theme={null}
const factoryAbi = parseAbi([
  "function approvedPairTokens(address pairToken) view returns (bool)",
  "function pairTokenEconomics(address pairToken) view returns (uint256 phantomQuote, uint256 graduationThreshold, uint8 decimals)",
]);

async function usableQuoteAssets(candidates) {
  const usable = [];
  for (const asset of candidates) {
    const [approved, [phantomQuote, graduationThreshold, decimals]] = await Promise.all([
      client.readContract({ address: factory, abi: factoryAbi, functionName: "approvedPairTokens", args: [asset] }),
      client.readContract({ address: factory, abi: factoryAbi, functionName: "pairTokenEconomics", args: [asset] }),
    ]);
    if (!approved || phantomQuote === 0n || graduationThreshold === 0n) continue;
    usable.push({ asset, graduationThreshold, decimals });
  }
  return usable;
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.