---
name: cpunks-mint
description: Hunt a valid CPUNKS timestamp and get a mint code. The user enters their wallet address and a timestamp — if it hits a valid slot in the active batch, a mintCode bound to that wallet is returned. Then the user pastes it on the site to mint.
allowed-tools: Bash(curl *)
---

## Task: Hunt a CPUNKS timestamp and get a mint code

You are helping the user hunt a valid timestamp in the active CPUNKS batch. Walk them through the steps below one at a time.

---

## Step 1 — Check the active batch

```bash
curl -s https://unixpunks.xyz/api/schedule
```

**Response shape:**
```json
{
  "activeBatch": 1,
  "windows": [
    {
      "batch": 1,
      "tsRangeStart": 1498176000,
      "tsRangeEnd": 1498185999,
      "timestampsCount": 1111,
      "consumedCount": 34
    }
  ]
}
```

- If `activeBatch` is `null` — tell the user no batch is active and show the next batch start time from `windows`. Stop.
- If active — tell the user:
  > "Batch N is live. Epoch range: **tsRangeStart – tsRangeEnd**. Pick any integer in that range to try. 1,111 out of 10,000 are winners."

---

## Step 2 — Ask for wallet address

Ask the user:
> "Enter your Ethereum wallet address (0x...):"

Validate:
- Starts with `0x`
- Exactly 42 characters
- Only hex characters after `0x`

If invalid, ask again.

---

## Step 3 — Ask for timestamp

Ask the user:
> "Enter a timestamp to try (integer, e.g. 1498176003):"

Remind them it must be within the active batch epoch range from Step 1.

---

## Step 4 — Submit timestamp

```bash
curl -s -X POST https://unixpunks.xyz/api/find-mint-code \
  -H 'content-type: application/json' \
  -d '{"timestamp": TIMESTAMP_INTEGER, "wallet": "0xUSER_WALLET"}'
```

**Important:** `timestamp` must be a JSON integer (no quotes). `wallet` must be a string with `0x` prefix.

**Correct example:**
```bash
curl -s -X POST https://unixpunks.xyz/api/find-mint-code \
  -H 'content-type: application/json' \
  -d '{"timestamp": 1498176003, "wallet": "0xAbCd...1234"}'
```

**Response shapes:**

| `error` field | Meaning |
|---|---|
| *(none, `ok: true`)* | Hit! `mintCode` is in the response |
| `invalid_wallet` | Wallet format wrong — re-validate |
| `invalid_timestamp` | Miss — timestamp not a winner, try another |
| `timestamp_already_used` | Already minted by someone else — try another |
| `timestamp_already_issued` | Someone got a code for this second just now — try another |
| `no_active_batch` | Batch closed between steps — re-check schedule |
| `rate_limit` | IP rate limited — wait `retryInMs` ms then retry |
| `rate_limit_wallet` | Wallet checked too many times — wait `retryInMs` ms |
| `timestamp_must_be_integer_seconds` | Sent a float or string — fix the request |

---

## Step 5 — Handle the result

**Hit (`ok: true`):**
```
✅ HIT — your mintCode:

  0x...64 hex chars...

Go to https://unixpunks.xyz, connect wallet 0xYOUR_WALLET, paste this code, and click Mint.

⚡ This code is bound to your wallet — only you can use it.
⚡ Act fast — first on-chain transaction wins. If someone else finds the same second, their tx may confirm first.
```

**Miss (`invalid_timestamp` or `timestamp_already_used` or `timestamp_already_issued`):**
```
❌ Miss. That second is not a winner.
```

Immediately suggest **5 new timestamps** to try next. Rules for suggestions:
- Generate them randomly from within `tsRangeStart – tsRangeEnd`
- **Never suggest a timestamp the user has already tried in this session**
- Space them out across the range (not clustered together)
- Present them as a numbered list so the user can just say "try 3" or pick one

Example format:
```
Here are 5 fresh seconds to try:
  1. 1498176842
  2. 1498179301
  3. 1498181055
  4. 1498183720
  5. 1498185100
```

**Already used / issued:**
```
⏱ Already claimed by someone else. Try one of these instead:
```
Then suggest 5 new timestamps as above.

**Rate limited:**
```
⏳ Rate limited. Wait X seconds before the next attempt.
```

---

## Step 6 — Offer to continue

After any miss, ask:
> "Which one do you want to try? (pick 1–5, enter your own, or say stop)"

- If they pick a number — submit that suggestion from Step 5
- If they enter their own timestamp — submit that
- Keep a running list of all tried timestamps this session to never re-suggest them
- Keep hunting until a hit or the user quits
