---
name: intear-launchpad
description: Build a token launchpad on NEAR (a site where anyone launches a token that trades right away) on Intear's stack. Covers forking, testing and deploying the launch factory from INTEARnear/launch (your own quote token, phantom liquidity, fees, short-ID price), launching with prepare_launch and launch_token, live tokens, prices, charts, trades, balances and positions from the Intear API, buying and selling through the Intear DEX Aggregator with /route/outcome, the app's trade fee and referral program, creator fee claims, and NEAR wallet connection. Use it whenever someone wants to build, fork, extend, audit or debug a launchpad, token launcher, bonding-curve or fair-launch site on NEAR, work with Plach launch pools or launch-v2.intear.near, or wire up buying and selling of freshly launched tokens, even if they don't say "Intear".
---

# Building a launchpad on NEAR with Intear

A launchpad is a thin layer over contracts and services that already exist. Your app mostly reads
data and builds transactions for the user's wallet to sign. The only contract you own is the
**launch factory**. Everything else (the token contract code, the AMM, routing, indexing) is shared
Intear infrastructure on NEAR mainnet.

Examples are plain TypeScript against `fetch`, `WebSocket` and a wallet's `signAndSendTransaction`,
so they port to any UI stack, a bot, or a backend. Last checked against the live contracts, docs and
APIs on 2026-11-02.

## How a launch works

```
creator ──prepare_launch (view)──▶ factory: token ID, errors, exact deposit
creator ──launch_token + deposit─▶ factory (your fork of INTEARnear/launch)
                                     │ 1. creates <symbol>-<n>.<factory> with the global FT code,
                                     │    the whole supply minted to the factory
                                     │ 2. registers the token and the quote asset in Intear DEX
                                     │ 3. moves the whole supply into the DEX
                                     │ 4. creates a Plach launch pool: all of the token vs. phantom
                                     │    liquidity of the quote asset (NEAR, or a NEP-141 like TEAR)
                                     │ 5. optional first buy for the creator, in the same operations
                                     ▼
traders ──aggregator route──▶ Plach launch pool ◀── fees per swap ──▶ creator, pool, protocol, your app
```

Things that surprise people:

- **No bonding-curve contract and no "graduation".** The launch pool *is* the curve: a
  constant-product pool whose quote side starts with virtual ("phantom") liquidity. The starting
  fully diluted value equals the phantom liquidity. Sells can only take out quote asset that buyers
  put in. Liquidity can never be added or removed, so it can't be rugged and it never migrates.
- **`launch_token` takes exactly one deposit amount**, the one `prepare_launch` returns, and panics
  otherwise. Never compute the deposit yourself.
- **Pool fees are fixed at launch** and paid on every swap through the pool, whoever's app sends it.
  Plach keeps 20% of each as its protocol fee. Your app's own trade fee (router `fees`) is only paid
  on trades that come through your app, once per trade, into your Intear DEX inner balance.
- **`launch_token` returns the new token ID right away, but the token, DEX registration and pool are
  made in later receipts.** Check every receipt. The token shows up in the Intear API a few blocks
  later.
- **Mainnet only.** The aggregator and Intear DEX don't run on testnet. Test a fork with the repo's
  sandbox suite (`cargo test`, real mainnet code), then on mainnet with throwaway amounts.
- The contracts aren't audited. Say so wherever users put money in.

## IDs and endpoints

| What | Value |
| --- | --- |
| Intear's factory (fork it, or launch on it) | `launch-v2.intear.near` (older: `launch.intear.near`) |
| Factory source | https://github.com/INTEARnear/launch (`src/lib.rs`, `tests/launch.rs`) |
| Token code (global contract hash) | `8D1NEU2NC2hKhdtCkHyyAz2KVmVXRazm9ZQMC27D97jF` (https://github.com/INTEARnear/global-ft-contract) |
| Intear DEX engine | `dex.intear.near` |
| Plach (the AMM, a DEX inside the engine) | DEX ID `slimedragon.near/xyk`, protocol fees to `plach.intear.near` |
| Quote tokens on Intear's factory | NEAR (300 NEAR phantom), USDC `17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1` (1,500), TEAR `token.intear.near` (100,000) |
| Intear API (tokens, prices, charts, trades, balances, positions) | `wss://api.intea.rs/ws`, `https://api.intea.rs`, schema at `https://api.intea.rs/schema` |
| DEX Aggregator | `https://router.intear.tech/route`, `/route/outcome`, `wss://router.intear.tech/route/subscribe` |
| dex-backend (undocumented: pools, fees, launch metadata) | `https://dex-backend.intear.tech` |
| Developers page: fees an account collected on each DEX, and withdrawing them | https://dex.intea.rs/developers |
| NEAR RPC | `https://free.rpc.fastnear.com`, `https://rpc.intea.rs` (key from https://rainy.intea.rs) |

## The pieces and where they live

| Piece | What you use | Read |
| --- | --- | --- |
| Launch factory | Your fork of `INTEARnear/launch` | `references/factory-contract.md` |
| Launching a token | `prepare_launch`, then `launch_token` with its deposit | `references/launching-tokens.md` |
| Tokens, prices, charts, trades, balances, positions | Intear API | `references/data-sources.md` |
| Launch metadata (links, description, creator) | Intear API `socials`/`description`/`dev`, or your factory's `get_launch_data` | `references/data-sources.md` |
| Pools and their fees | dex-backend `/pools/all`, or Plach `get_pool` on chain | `references/data-sources.md` |
| Buying and selling | Aggregator routes, then `/route/outcome` | `references/trading-and-routes.md` |
| Your revenue, referrals, creator fees | Router `fees` (Intear DEX referral fees), `withdraw`, Plach `withdraw_fees` for creators | `references/fees-and-referrals.md` |
| Wallet | NEAR Connect (`@hot-labs/near-connect`) in browsers, near-api-js or near-kit on servers | `references/wallet.md` |

Read the references for the parts you're working on. Each one is self-contained.

### Bundled code (copy into the project)

All TypeScript, type-checked together, no dependencies except NEAR Connect in `wallet.ts`:

- `assets/launch.ts`: `prepareLaunch`, `launchTokenTransaction` (prepare + exact deposit + gas),
  `depositQuoteTokenTransactions` for NEP-141 first buys, `editTokenTransaction`, and a UTF-8-safe
  RPC `view()`.
- `assets/router.ts`: `getRoutes`, `RouteSocket` (live quotes for one request at a time), and
  `executeRoute`, which sends a quote's transactions one by one, asks `/route/outcome`, sends fee
  transactions only if the swap went through, and runs `next_steps`.
- `assets/intear-api.ts`: `IntearApi`, the WebSocket client (waits for hello, reconnects with
  backoff, makes subscriptions again with fresh params so they resume, closes them cleanly), plus
  `intearApiHttp`, `objectsOf` and `iconUrl`.
- `assets/wallet.ts`: a NEAR Connect `Wallet` that restores sessions and signs.
- `assets/outcomes.ts`: `assertSucceeded` (every receipt), `returnValue` (the new token ID from
  `launch_token`), `transactionHash`.

Prefer these to writing new clients. They handle the exact-deposit, reconnect, id-matching and
fee-transaction details that otherwise take a few rounds of bugs.

## Building one: the order that works

1. **Decide the economics before writing UI.** Which quote assets (NEAR, your token, a stablecoin)?
   How much phantom liquidity for each (it sets the starting price and how fast it moves)? What fees
   do creators get to set, and does your platform take a pool fee, a router fee, or both? These live
   in the factory and in your app, and pool fees can't change after launch. See
   `references/factory-contract.md` ("Tuning") and `references/fees-and-referrals.md`.
2. **Fork, change, test and deploy the factory**, and do the one-time setup of each quote asset.
   The factory's account name becomes the suffix of every token ID (`ticker-1.<factory>`), and NEAR
   account IDs are at most 64 characters, so keep it short.
3. **List launches.** Intear API `tokens.subscribe` with `where: { parent: "<factory>" }` gives every
   token your factory made, live, with prices and stats.
4. **Token page.** Candles (`candles.subscribe`), trades (`trades.subscribe` with history), the
   pool's fee configuration, the creator and links.
5. **Trading.** Follow a live route for the amount the user types, then `executeRoute` and show what
   `/route/outcome` reports.
6. **Launch form.** Call `prepare_launch` as the form changes and show its errors and token ID, then
   send `launch_token` with its deposit and open the new token's page once the API has it.
7. **Fees and referrals.** Pass `trader_account_id` on every route, so routes register your fee
   accounts for the input asset. Without that, unregistered accounts silently aren't paid. Then add
   claim flows: `withdraw` for app and referral fees, Plach `withdraw_fees` then `withdraw` for
   creators.
8. **Wallet balances and PnL.** `balances.subscribe` for the connected account (native NEAR is
   `near`, wrapped is `wrap.near`), and `positions.get` for cost and PnL.

## Conventions that cause most bugs

- **Amounts are integers in the token's smallest units**, as strings in JSON. NEAR has 24 decimals
  (yoctoNEAR). Use `BigInt` and never floats for anything you send. `total_supply × 10^decimals` must
  fit in a u128 (about 3.4e38): with 24 decimals that's at most about 3.4e14 whole tokens.
- **Three names for NEAR.** The router and the Intear API's balances and transfers use `near` for
  native NEAR. The Intear API's token data and trades use `wrap.near`. Intear DEX asset IDs are
  `near` and `nep141:<token>`.
- **Gas is in gas units, deposits in yoctoNEAR**, both as strings in wallet actions
  (`"300000000000000"` is 300 TGas, and a transaction can have at most 1,000 TGas). Methods that move
  tokens need exactly `"1"` yocto attached.
- **Fee fractions:** Plach, the factory and Intear DEX's `referral_fees` use `u32` out of 1,000,000
  (`3000` = 0.3%). The router's `fees` parameter uses decimal fractions (`0.005` = 0.5%) in whole
  millionths, at most 4 accounts and 5% in total. A pool's fees total at most 90%, and Plach keeps a
  fifth of each.
- **Wallets resolve even when a receipt failed.** For launches, walk every receipt
  (`assertSucceeded`). For swaps, ask `/route/outcome` (`executeRoute`).
- **Fee transactions are conditional.** Send a route's `is_fee_transaction` transactions only when
  `/route/outcome` says `charge_fee: true`.
- **Live feeds reconnect.** Both websockets drop. The Intear API lets each subscription pick up where
  it left off (`resume_from`, `after_id`). The router just takes the request again. Ignore router
  updates whose `id` isn't the latest you sent.
- **Encode args as UTF-8.** Token names and descriptions have emoji: `btoa(JSON.stringify(...))`
  throws on them. `view()` in `assets/launch.ts` encodes correctly.

## When things are unclear

The live sources are the truth and change faster than this skill: the factory gained
`prepare_launch` and dropped `preview_id` and `long_id_cost` in October 2026, app fees moved from
Plach to Intear DEX's `referral_fees` in late October, and Plach's protocol fee became 20% of each
fee, with payout types and claim modes for receivers, on 2026-11-01. Check before relying on a
detail:

- Plach and Intear DEX: `git log` in https://github.com/INTEARnear/dex (`dexes/xyk` is Plach). A
  change of Plach's Borsh types needs a factory update (`factory-contract.md`, "Running it").
- Factory: read `src/lib.rs` and `git log` in https://github.com/INTEARnear/launch, and call
  `prepare_launch` on the live factory (`view()` in `assets/launch.ts`, or near CLI as in
  `references/factory-contract.md`).
- Intear docs as Markdown: https://docs.intear.tech/llms.txt lists every page, a page's URL with
  `.md` in place of the trailing slash is that page, and `/<product>/llms-full.txt` is a whole
  product (`api`, `dex-aggregator`, `plach`, `intear-dex`). Code samples there are tested in CI.
- Intear's per-product agent skills, for depth beyond a launchpad:
  https://docs.intear.tech/skills/intear-api/SKILL.md, `intear-dex-aggregator`, `intear-plach`,
  `intear-dex` (same URL pattern).
- Intear API fields and limits: `GET https://api.intea.rs/schema`.
- dex-backend is undocumented. The endpoints in `references/data-sources.md` are what Intear's own
  launchpad uses. Check their shape with a quick request before relying on them.
