---
name: niudan
description: |
  Use when the user wants to play NIUDAN (扭蛋) on BNB Chain: a 7-day capsule machine for AI agents with a .ai Agent ID.
  Buy capsules (0.01 BNB, 10 per agent per round), see the odds, draw ended rounds, check results, claim prizes, launch
  the NIU pool. It is a game of chance: on average a capsule pays back 70% in BNB.
  Triggers: niudan, 扭蛋, capsule machine, gacha, spin a capsule, niu token, jackpot draw, claim my prize.
metadata:
  version: '0.2.0'
  requires:
    bins: [baw]
---

# NIUDAN (扭蛋) skill

NIUDAN is a capsule machine on BNB Chain for AI agents (Binance Agentic Wallets holding a **.ai Agent ID**). A season
has **7 daily rounds**. Each round's capsules are drawn after it ends, from the hash of a future block.

| | |
|---|---|
| Capsule | **0.01 BNB**, **1–10 per transaction, 10 per agent per round** |
| Every capsule | **10,000 NIU** at once (locked until launch), win or lose |
| Prizes per round | **1 JACKPOT** (the rest of the prize pot) · **2% GOLD 10×** · **6% SILVER 3×** · **20% BRONZE 1×** (money back) · **~72% nothing** |
| Where the BNB goes | **70%** prizes · **10%** NIU pool at launch · **20%** treasury |
| Average return | **0.007 BNB per 0.01 BNB capsule** (+ the NIU). Most capsules lose |
| Launch | after the season, once every round is drawn (anyone): 10% BNB + 10,000 NIU per capsule → PancakeSwap, LP burned, NIU unlocks |

Nothing to install except the Binance Agentic Wallet CLI (`baw`). Read the chain with `eth_call`, send with
`baw contract-call preview` → show it → `baw contract-call execute` only after the user's explicit yes.
**Never ask the user for a private key or seed phrase.**

- Machine (NIUDAN): `0xCE1741296C4Be8F0552E0C78FaB795ddBA5d5eA3`
- Token ($NIU): `0xB91F52df01B759f39511886CCf69AC0930c10043`
- Website: `https://niudan-4z2.pages.dev`
- BSC RPC: `https://bsc-dataseed.bnbchain.org` · chain 56

## Rules for you, the agent — this is gambling
- Buy capsules **only when the user asks**, for the number they name. Before sending, tell them: cost, odds
  (~72% of capsules win nothing), average return 70%. Wait for an explicit **yes**.
- **Never** spin on your own, on a schedule, in a loop, "to win it back" after a loss, or to reach a target.
- If the user set a budget, keep a running total and stop at it. Suggest one if they didn't.
- Never describe capsules as an investment or a way to earn. Never promise a win, a multiplier or a NIU price.
- If the user seems to be chasing losses or in distress, stop and say so kindly.
- Say that the contracts are unaudited and that gambling is restricted or illegal in many places (18+ at least).

## Read (eth_call, no signing)
`W` = the wallet address without `0x`, lower-case, left-padded to 64 hex chars.

| what | data |
|---|---|
| current round (0–6; 7+ = season over) | `0x8a19c8bc` (`currentRound()`) |
| me: isAgent, handle, left this round, pending BNB, NIU | `0x62c885ee` + `W` (`agentInfo(address)`) |
| unclaimed prizes | `0xf44136a1` + `W` (`pendingOf(address)`) |
| my capsules in round r | `ticketsOf(uint256,address)` = `0x09c79735` + r (64 hex) + `W` |
| what capsule t of round r won | `tierOf(uint256,uint256)` = `0x7c9ab169` + r + t → (tier 0 none · 1 bronze · 2 silver · 3 gold · 4 jackpot, prize wei) |

```bash
curl -s https://bsc-dataseed.bnbchain.org -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"0xCE1741296C4Be8F0552E0C78FaB795ddBA5d5eA3","data":"0x8a19c8bc"},"latest"]}'
```

## Spin (only on request) — `spin(uint256 count)` = `0xa5b6ea8f`
`data` = `0xa5b6ea8f` + count as 64 hex chars. `value` = count × 0.01 BNB **in wei** (1 capsule = `10000000000000000`).

```bash
# 3 capsules = 0.03 BNB
baw contract-call preview --binanceChainId 56 --from <wallet> --to 0xCE1741296C4Be8F0552E0C78FaB795ddBA5d5eA3 \
  --value 30000000000000000 \
  --inputData 0xa5b6ea8f0000000000000000000000000000000000000000000000000000000000000003 --json
# show cost + odds + 70% average return, wait for "yes", then:
baw contract-call execute --requestId <id> --json
```

## Draws (anyone, after a round ends) — `draw(uint256 r)` = `0x3b304147` + r
The 1st call arms the draw on a block ~5 blocks ahead; call it again after that block to draw. (The site runs these too.)

## Claim — `claim()` = `0x4e71d92d`, value 0
Collect every prize you won, any time after the draw.

## After the season — `launch()` = `0x01339c21`, value 0
Anyone, once all 7 rounds are drawn. Then NIU trades on PancakeSwap V2 (router `0x10ED43C718714eb63d5aA57B78B54704E256024E`).

## Errors
`NotAnAgent` · `SeasonClosed` · `RoundLimit(left)` · `SoldOut(left)` · `Underpaid(cost)` · `RoundNotOver` ·
`TooEarly(drawBlock)` · `AlreadyDrawn` · `NothingToClaim` · `NotReady` · `Locked` (NIU before launch).
