---
name: second
description: Join or create a fair launch on SECOND (Solana, pump.fun), where the public buys first and the dev buys second. Pool SOL into a launch's pot, leave before the lock, create a launch with a dev buy, read launches, fills, the dev premium and the tape. Use when an agent or a user wants to join, leave, create or check a SECOND launch.
---

# SECOND: the dev buys second

SECOND is a pump.fun launchpad on Solana. On every other pad the dev buys first, at the bottom. On SECOND
the public buys first: everyone pools SOL into a launch's pot, and at the start ONE transaction creates the
coin on pump.fun, buys with the whole pot (every wallet, same price), and THEN buys the dev's bag, at the
higher price the pot just pushed the curve to. The dev's bag is locked **7 days**.

Base URL: `https://secondbuy.fun`. Every endpoint is JSON, CORS-open, snake_case. Every SOL amount is a string of
lamports (1 SOL = 1,000,000,000 lamports) with a plain number twin ending in `_sol`; tokens are plain
numbers ending in `_ui` (pump.fun coins have 6 decimals). Times are ISO 8601. Errors are
`{ "error": "<code>", "message": "<plain English>" }`.

The server never holds your keys. Write endpoints return **unsigned** transactions: your wallet signs and
sends them, then you call `POST /api/confirm`. Each launch has its own vault address (`vault`); only the
pad's crank signs for it, and only by the rules below.

## The rules, with every number

1. **A launch**: a name (1 to 32 bytes), a ticker (2 to 10 of A-Z 0-9; `$cat` is `CAT`), a description,
   an image (an https link, a data: URL or base64; none: one is drawn from the ticker), optional X and
   website links, and:
   - a start **30 minutes to 24 hours** after it is created, rounded up to the next **5-minute** mark;
   - a min pot (default **1 SOL**, at least **0.5 SOL**), min wallets (default **10**, at least **3**), a max
     pot (default **50 SOL**, at most **75 SOL**: a pump.fun curve graduates at about 85 SOL);
   - a dev buy of **0** or **0.01 to 5 SOL**, never more than the min pot.
2. **Creating**: the launcher signs one transaction: the dev buy + a **0.02 SOL** listing fee into the
   launch's own vault, memo `second:dev:v1:<id>`. The listing fee pays pump.fun's create rent and the
   network fees. If the launch refunds, it is refunded too.
3. **Joining**: a plain SOL transfer into the launch's vault with memo `second:join:v1:<id>`. Each join is at
   least **0.01 SOL**; one wallet's joins add up to at most **5 SOL**. A join that would push the pot over its
   max pot is refunded in full. So is a join that lands after the lock, and the launcher joining their own
   launch.
4. **Leaving**: until the lock, sign the exact text `second:leave:v1:<id>:<unix seconds>` (ed25519 message
   signature, base58 or base64; the time at most 10 minutes old) and send it to `POST /api/leave`.
   Everything you put in is refunded in full.
5. **The lock** is **5 minutes before the start**. If the pot is under its min pot, or fewer wallets than
   its min wallets are in, everyone (the dev buy and the listing fee too) is refunded in full.
6. **The start**: one transaction, signed by the launch's vault and a fresh mint:
   1. pump.fun `create_v2` with the launcher as the coin's creator (the creator fees are the launcher's),
   2. buy #1 with the pot, less the **1%** pad fee and **0.0021 SOL** per wallet (the token account each
      wallet's tokens are sent to),
   3. buy #2 with the dev buy, less **1%** and **0.0021 SOL** (the launcher's token account).
   Both fills are recorded: `public_price_sol` and `dev_price_sol` (SOL per token). The dev always pays more
   per token: `dev_premium_pct` says how much. If the transaction fails it is tried again (a new mint each
   time) up to **3** times, then everyone is refunded in full.
7. **Tokens**: the public tokens are sent to every wallet pro rata to its SOL in (in batches by the crank,
   which creates the token accounts). The rounding dust goes to the last wallet that joined, so every token
   leaves the vault. The dev's tokens stay in the vault **7 days**, then are sent to the launcher.
8. **The pad fee**: 1% of the pot and 1% of the dev buy, only when the coin launches. It goes to the pad's
   treasury and buys and burns $SECOND. What is left in a vault once everything is sent goes there too.
9. **Refunds** are sent by the crank in full. A refused payment under **0.001 SOL** is kept (a refund that
   small could fail for good).
10. The crank runs every 5 minutes; the site also triggers the lock and the start on time.

## Read

| Endpoint | Answer |
| --- | --- |
| `GET /api/stats` | `launches_filling`, `launches_launched`, `wallets_joined`, `sol_pooled`, `sol_pooled_sol`, `avg_dev_premium_pct`, `second_burned_ui`, `treasury`, `second_mint`, `last_crank` |
| `GET /api/launches?status=filling\|launched\|refunded\|all&limit=50` | `{ launches: [Launch] }` (filling = filling and locked, soonest start first) |
| `GET /api/launch?id=<id>` | `{ launch: Launch, joins: [Join], receipt: Receipt \| null }` |
| `GET /api/tape?limit=50&id=<id>` | `{ events: [{ kind, id, ticker, wallet, sol, tokens_ui, sig, at }] }` newest first; kinds: create, join, leave, lock, launch, refund, send, unlock, burn |
| `GET /api/me?wallet=<address>` | `{ joins: [Join + { id, launch }], launches: [Launch] }` (the wallet's joins, and the launches it created) |

`Launch` = `{ id, name, ticker, description, image, twitter, website, launcher, vault, status (filling | locked |
launched | refunded), created_at, start_at, lock_at, launched_at, pot, pot_sol, wallets, min_pot_sol, min_wallets,
max_pot_sol, dev_sol, mint, create_sig, public_price_sol, dev_price_sol, dev_premium_pct, dev_unlock_at,
refund_reason }`.

`Join` = `{ wallet, sol_in, sol_in_sol, joined_at, left_at, tokens_ui, sent_sig }` (one line per wallet;
`tokens_ui` once the coin launched, `sent_sig` once its tokens were sent).

`Receipt` = `{ mint, create_sig, public_sol, public_tokens_ui, public_price_sol, dev_sol, dev_tokens_ui,
dev_price_sol, dev_premium_pct, fee_sol, sent_wallets, total_wallets, dev_unlock_at, dev_unlocked_sig }`.

## Write

1. **Join**: `POST /api/join { "wallet": "<address>", "id": "<id>", "sol": 0.5 }` (or `"lamports": "500000000"`)
   answers `{ transaction, vault, lamports, sol, memo, lock_at, launch, ... }`. Sign `transaction` (base64,
   unsigned, your wallet pays the fee), send it, then `POST /api/confirm { "sig": "<its signature>" }`.
2. **Leave**: sign `second:leave:v1:<id>:<unix seconds>` with the wallet, then
   `POST /api/leave { "wallet", "id", "ts": <the unix seconds>, "signature": "<base58 or base64>" }` answers
   `{ ok: true, refund: "queued", lamports, sol, launch }`.
3. **Create**: `POST /api/create { "wallet", "name", "ticker", "description", "image", "twitter", "website",
   "start_in_minutes": 60, "min_pot_sol": 1, "min_wallets": 10, "max_pot_sol": 50, "dev_sol": 0.5 }` answers
   `{ id, vault, transaction, start_at, lock_at, lamports, sol, memo, image, uri, ... }`. Sign and send the
   transaction (dev buy + 0.02 SOL), then `POST /api/confirm { "sig" }`: the launch opens for joins.
4. **Confirm**: `POST /api/confirm { "sig" }` verifies a create or join on chain and records it: `{ ok, kind
   (create | join), id, accepted, reason, message, refund, kept, launch }`. A refused payment is recorded
   too (`accepted: false`, `reason`) and refunded in full by the crank.

Raw transfers work too (any wallet, any tool): send SOL to the launch's `vault` with the memo
`second:join:v1:<id>` signed by the sending wallet (the fee payer). The crank finds payments nobody confirmed
in the vault's history, but confirm them yourself so the pot shows them at once.

## Errors

`bad_json`, `too_large`, `bad_wallet`, `bad_id`, `bad_status`, `bad_ticker`, `bad_name`, `bad_description`,
`bad_image`, `image_too_large`, `bad_link`, `bad_start`, `bad_min_pot`, `bad_min_wallets`, `bad_max_pot`,
`bad_dev`, `bad_amount`, `not_found`, `not_open`, `locked`, `own_launch`, `below_min`, `wallet_cap`, `pot_full`,
`not_joined`, `bad_ts`, `bad_signature`, `expired`, `in_future`, `stale`, `bad_sig`, `tx_not_found`, `tx_failed`,
`not_second`, `malformed`, `insufficient_sol`, `rate_limited` (with `retry_after`), `not_configured`, `busy`,
`upstream`.

Refusal reasons of a recorded payment: `duplicate`, `not_launcher`, `wrong_amount`, `late`, `not_open`,
`after_lock`, `own_launch`, `below_min`, `wallet_cap`, `over_max`, `no_launch`.

Limits: 30 joins / leaves per wallet per minute (120 per caller address); 6 creates per wallet per
10 minutes (20 per caller address).
