# DNALAB — create an AI digital human token (agent instructions)

DNALAB turns one sentence into an AI digital human and launches it as a token on gang.fun (BNB Chain, LaunchpadV2).
You, the agent, do three things: draft the human on DNALAB, sign gang.fun's `create` with the user's Binance Agentic
Wallet, and register the token back on DNALAB. Launching costs only BSC gas.

Base URL: `https://dnalab.fun`

## Requirements

- The user has a **Binance Agentic Wallet** with a **SPACE ID Agent ID (`.ai`)** and **Developer Mode** on. gang.fun's
  contract rejects `create` / `buy` / `sell` from any wallet without an Agent ID (`NotAgent`).
- `baw` CLI signed in (`baw auth signin`). Install the skill if missing:
  `npx skills add binance/binance-skills-hub/skills/binance-web3/binance-agentic-wallet`
- Before any `contract-call`, run `baw wallet settings --json` and confirm `devMode.enabled=true`.

## 1. Draft

```bash
curl -s -X POST https://dnalab.fun/api/draft \
  -H 'content-type: application/json' \
  -d '{"prompt":"<the user sentence>","wallet":"<agentic wallet address>"}'
```

Optional fields: `"name"` / `"symbol"` (fixed instead of the model's pick; symbol 2–10 letters/digits),
`"twitter"` (`@handle` or x.com link), `"website"` (defaults to `https://dnalab.fun/`; pass `null` for none). Website
and X link are embedded in `create.data` and shown on gang.fun; they are permanent.

Response (201):

```json
{
  "id": "4f1c…", "name": "Luna", "symbol": "LUNA", "bio": "…", "look": "…", "niche": "…", "vibe": "…",
  "template": "nova", "image": "/templates/nova.jpg",
  "logoUri": "https://cdn.gang.fun/ipfs/…",
  "isAgent": true,
  "create": { "to": "0x1B8F3f69DFa0a7F63d308C7EB0Fd38D8b099966E", "data": "0x1abdc752…", "value": "0" }
}
```

- `isAgent: false` → stop and tell the user to claim an Agent ID in the Binance App first.
- Show the user `name`, `symbol`, `bio` and the portrait (`https://dnalab.fun` + `image`). If they want another
  take, POST `/api/draft` again with a changed sentence (drafts are free). To force a portrait template pass
  `"template":"<id>"` (ids: nova, kai, mei, rex, yuki, sage, zero, luna).
- Own photo instead of a template (png/jpeg/webp/gif ≤ 512 KB):
  `curl -s -X POST https://dnalab.fun/api/draft/<id> -F file=@portrait.jpg` → same JSON with the new `image`,
  `logoUri` and `create.data`. Always use the **latest** `create.data`: the logo URL is inside it and is permanent on-chain.

## 2. Launch (user confirms in the Binance App)

```bash
baw contract-call preview --binanceChainId 56 --from <wallet> --to <create.to> --value 0 --inputData <create.data> --json
# show the user: name, symbol, portrait, "gang.fun LaunchpadV2.create, costs gas only" → wait for an explicit yes
baw contract-call execute --requestId <requestId from preview> --json
# status PENDING_CONFIRMATION → the user approves in the Binance App; then
baw wallet tx-history --binanceChainId 56 --type confirmed --json   # → txHash
```

Then read the token address from the receipt: the `Created` event of `0x1B8F…966E` (topic0
`Created(address,address,string,string,string,bool,address,address,uint256)`, `token` = topic 1), or simply pass the tx
hash to step 3.

Optional first buy (the curve is quoted in **WBNB**, not native BNB, so it is three more calls, each previewed and
approved the same way): `WBNB.deposit()` with `--value <wei>`, `WBNB.approve(0x1B8F…966E, <wei>)`, then
`LaunchpadV2.buy(token, <wei>, <minTokensOut>)`. One wallet can hold at most 1 % of supply (10,000,000 tokens);
on a fresh curve that is ≈ 0.048 BNB — anything above is refunded as WBNB. `create` itself cannot buy.

If preview fails with `NotAgent`, the wallet has no Agent ID. `MigratorNotSet` / other contract errors: report them as is.

## 3. Register on DNALAB

```bash
curl -s -X POST https://dnalab.fun/api/claim -H 'content-type: application/json' -d '{"tx":"<tx hash>"}'
# or {"token":"0x<token address>"}
```

Response: `{ "address": "0x…", "symbol": "LUNA", "created": true, "url": "https://dnalab.fun/t/0x…" }`.
Idempotent: call it again if anything timed out. Give the user the `url` and the gang.fun page
`https://gang.fun/token/<address>`.

## Trading

The curve is agent-only too. Use the gang.fun CLI (`npm i -g @gangfun/cli@latest`, skill
`npx skills add gangfun/gang-launchpad/skill`):

```bash
gang quote --token <address> --bnb 0.05
gang buy   --token <address> --bnb 0.05   # preview → user confirms → gang execute --request-id …
gang sell  --token <address> --all
```

Rules on the curve: 1 % fee per trade, 1 % of supply per wallet, no transfers before graduation (≈ 15 BNB), then
PancakeSwap V2 with LP burned.

## Read

- `GET /api/tokens` — all DNALAB humans with live price / market cap.
- `GET /api/tokens/<address>` — one token (works for any LaunchpadV2 token; `registered: false` if not from DNALAB).
