# Hot.fun Create Token API Reference

## Flow

The `hotfun create-token` command handles the full flow in a single invocation:

1. **Call API** — POST to the hot.fun API with token parameters; receive a base58-encoded Solana transaction.
2. **Sign** — Deserialize the transaction and sign it with the wallet private key.
3. **Send** — Send the signed transaction to Solana RPC and confirm.

## API Endpoint

| Method | Endpoint |
|--------|----------|
| POST | `https://gate.game.com/v3/hotfun/agent/create_pool_with_config` |

### Request

**Content-Type**: `multipart/form-data`

| Parameter | Required | Description |
|-----------|----------|-------------|
| `payer` | Yes | Solana wallet public key (derived from PRIVATE_KEY) |
| `name` | Yes | Token name, max 255 chars |
| `symbol` | Yes | Token symbol, max 32 chars |
| `image_url` | Yes | Token image URL (e.g. IPFS link) |
| `agent_ts` | Yes | Current Unix timestamp (valid for 5 minutes) |
| `agent_sign` | Yes | Ed25519 signature of `agent_ts` using wallet private key, base58 encoded |
| `description` | No | Token description |
| `x_royalty_party` | No | X (Twitter) username for royalty party |

### Response

```json
{
  "data": {
    "transaction": "<base58-encoded Solana transaction>",
    "signature": "",
    "dbc_config": "<pubkey>",
    "dbc_pool": "<pubkey>",
    "base_mint": "<pubkey>",
    "name": "MyToken",
    "symbol": "MTK",
    "uri": "<metadata URI>",
    "royalty_party": "<pubkey>"
  },
  "common": {
    "timestamp": 1772948092,
    "app_name": "hotfunv3",
    "chain_asset_config": [...],
    "config": { "check_chinese_symbol_duplicate": false }
  }
}
```

**Key fields in `data`**:

| Field | Description |
|-------|-------------|
| `transaction` | Base58-encoded Solana transaction to sign and send |
| `base_mint` | The new token's mint address |
| `dbc_config` | DBC config account |
| `dbc_pool` | DBC pool account |
| `uri` | Token metadata URI (generated by API) |
| `royalty_party` | Royalty party account |

### Example

```bash
curl --request POST \
  --url https://gate.game.com/v3/hotfun/agent/create_pool_with_config \
  --header 'content-type: multipart/form-data' \
  --form payer=<WALLET_PUBKEY> \
  --form 'name=MyToken' \
  --form 'symbol=MTK' \
  --form image_url=https://example.com/image.png \
  --form 'description=A cool token' \
  --form x_royalty_party=myTwitter \
  --form agent_ts=1772947790 \
  --form agent_sign=<BASE58_ED25519_SIGNATURE>
```

## Authentication (agent_ts + agent_sign)

To prevent abuse, the API requires request authentication:

1. Generate `agent_ts`: current Unix timestamp in seconds.
2. Generate `agent_sign`: sign the `agent_ts` string using the wallet's Ed25519 private key, then base58-encode the 64-byte signature.
3. The timestamp is valid for 5 minutes from generation.

## Sign and Send

1. Decode the base58 `transaction` string to bytes.
2. Deserialize as a `VersionedTransaction`.
3. Sign with the wallet `Keypair`.
4. Send via `connection.sendRawTransaction()`.
5. Confirm via `connection.confirmTransaction()`.
