> ## Documentation Index
> Fetch the complete documentation index at: https://docs.o1.exchange/llms.txt
> Use this file to discover all available pages before exploring further.

# Direct contract integration

> Read current launch configuration, build safe launch transactions, trade through Uniswap v4, and consume canonical launch events.

This page intentionally uses exact contract fields for developers. For a plain-language product flow, start with [How it works](/launchpad/how-it-works).

Direct integrations should discover the active chain and creation route, read current factory state, build an unsigned transaction, and let the user's wallet sign it. Never hardcode a mutable configuration version, opening frame, or creation fee.

## Integration sequence

<Steps>
  <Step title="Select the active route">
    Resolve the current factory by chain and route. Use the crypto factory for ETH, USDC, or USDG, and the stock factory for a supported Stock Token. Do not infer the route from a symbol.
  </Step>

  <Step title="Read launch configuration">
    Read `configVersion`, `launchSupply`, `tickSpacing`, `feeDefaults`, `bands`, and `quotes(selectedQuote)` at one recent block. For a stock factory, also read `launchCreationEnabled`, `nativeLaunchFee`, and `quoteRevision(selectedQuote)`.
  </Step>

  <Step title="Validate parameters">
    Apply the hard limits in [Limits and validation](/launchpad/reference/limits), confirm the quote remains registered, and calculate the pool supply after allocations.
  </Step>

  <Step title="Build payment">
    Creation is currently free, so the production transaction sends no launch fee. Still read the route's live fee field: standard factories use `quotes(selectedQuote).creationFee`, while stock factories use `nativeLaunchFee`. If governance later sets a non-zero value, follow the active factory's exact currency rule.
  </Step>

  <Step title="Commit to the configuration">
    Set `expectedConfigVersion` to the fresh read and choose a short chain-time deadline. The o1 Launchpad interface uses the latest block timestamp plus 30 minutes. Stock tick-only updates advance the selected quote revision without changing the global version, so execution intentionally uses the latest registered opening frame.
  </Step>

  <Step title="Simulate, sign, and confirm">
    Simulate `createLaunch`, present all recipients and economics to the user, then request a wallet signature and wait for a successful receipt.
  </Step>

  <Step title="Parse canonical events">
    Read `Launched` for token and pool ID, then index the other factory, hook, PoolManager, escrow, vesting, and announcement events from the same transaction. For trades, derive direction and wallet attribution from the complete receipt rather than treating `Trade.executor` as the user's address.
  </Step>
</Steps>

## Read the current snapshot with viem

The example below reads the Base crypto factory. For another route, use its current factory and paired-asset addresses from [Production contracts](/launchpad/reference/production-contracts).

```ts theme={null} theme={null}
import { createPublicClient, http, parseAbi, zeroAddress } from "viem";
import { base } from "viem/chains";

const FACTORY = "0xa52ad458cE0282a971ecC71C051A32f28946bb9F";
const factoryReads = parseAbi([
  "function configVersion() view returns (uint64)",
  "function launchSupply() view returns (uint256)",
  "function tickSpacing() view returns (int24)",
  "function quotes(address) view returns (bool registered,uint8 decimals,int24 startTickToken0Frame,uint256 creationFee)",
  "function feeDefaults() view returns (uint16 baseFeeBps,uint16 creatorBps,uint16 platformBps,uint16 referrerBps,uint16 antiSnipeStartTotalBps,uint32 antiSnipeWindowSeconds,address platformTreasury)",
]);

const client = createPublicClient({ chain: base, transport: http() });
const [version, supply, spacing, nativeQuote, fees] = await Promise.all([
  client.readContract({ address: FACTORY, abi: factoryReads, functionName: "configVersion" }),
  client.readContract({ address: FACTORY, abi: factoryReads, functionName: "launchSupply" }),
  client.readContract({ address: FACTORY, abi: factoryReads, functionName: "tickSpacing" }),
  client.readContract({ address: FACTORY, abi: factoryReads, functionName: "quotes", args: [zeroAddress] }),
  client.readContract({ address: FACTORY, abi: factoryReads, functionName: "feeDefaults" }),
]);
```

For a transaction integration, obtain the complete verified factory ABI from the chain explorer. `LaunchParams` contains nested vesting arrays, so a partial handwritten write ABI is easy to get wrong.

`startTickToken0Frame` is the factory's internal opening-price encoding for a registered quote. The factory handles token ordering and tick spacing when it creates the pool; a launch transaction selects the quote and does not submit a starting tick.

## Stock-route reads

Add these reads when the selected pair belongs to a stock suite:

```ts theme={null} theme={null}
const stockFactoryReads = parseAbi([
  "function launchCreationEnabled() view returns (bool)",
  "function nativeLaunchFee() view returns (uint256)",
  "function quoteRevision(address) view returns (uint64)",
  "function TOKEN_ADDRESS_SUFFIX() view returns (uint8)",
]);
```

Fail closed unless creation is enabled, the Stock Token is registered on the selected stock factory, and the address-suffix constant is `1`. Robinhood stock launches must prepare the finalized token metadata first, read `launchTokenBytecodeHash`, and mine a salt whose predicted ERC-20 address ends in `01`. Base B20 addresses can be predicted before signing through the B20 creation formula.

## `LaunchParams`

| Field                                       | Meaning                                                        |
| ------------------------------------------- | -------------------------------------------------------------- |
| `name`, `symbol`                            | Token identity                                                 |
| `contractURI`                               | Pinned token metadata URI                                      |
| `salt`                                      | User salt, scoped by factory to the caller                     |
| `quote`                                     | Registered paired-asset address; zero address means native ETH |
| `allocationRecipients`, `allocationAmounts` | Parallel immediate allocation arrays                           |
| `vestedAllocations`                         | Beneficiary, amount, and cumulative staircase steps            |
| `expectedConfigVersion`                     | Exact fresh factory version                                    |
| `deadline`                                  | Latest allowed chain timestamp                                 |
| `roleMode`                                  | `0` for immutable metadata, `1` for metadata authority         |
| `metadataKeys`, `metadataValues`            | Parallel on-chain metadata arrays                              |

## Trading integration

Launch pools are ordinary Uniswap v4 pools with a required hook. Use the listed v4 Quoter for price discovery and the Universal Router plus Permit2 for execution. Preserve the exact pool key: sorted currencies, LP fee `0`, launch tick spacing, and the hook address frozen into that launch's contract suite.

`tickSpacing` is part of the exact Uniswap pool identifier and controls valid liquidity range boundaries. The current value `200` represents about 2.02% between allowed boundaries; it does not make swap prices move in fixed 2.02% increments.

Use exact-input during the anti-snipe window. Encode optional hook data as the referrer address followed by a `bytes32` comment. Simulate at current timestamp and include slippage and deadline protection. Current pools charge hook fees in the paired asset, including the selected Stock Token for stock-paired markets.

## Failure handling

For user launches, treat `StaleConfig` and `LaunchExpired` as refresh-and-rebuild errors. `StaleQuoteRevision` applies to restricted stock opening-price updates, not to launch submission. Treat quote removal, disabled stock creation, fee mismatch, invalid `01` suffix, allocation validation, salt reuse, immutability, and single-sided failures as blocking errors that require changed inputs or configuration. Do not silently fall back to another factory, route, or quote.
