# CRYPTOSYM Genesis — Mint & Holder Lottery Skill for Agents

- **Project**: CRYPTOSYM (`CSYM`) — Genesis 3D Trading Card
- **Site**: https://cryptosim.online
- **Manifest**: https://cryptosim.online/mint.json
- **Skill URL**: https://cryptosim.online/cryptosym-lottery-skill.md
- **Network**: BNB Smart Chain Mainnet (`chainId: 56`, currency: `BNB`)
- **Chainlink BNB/USD Feed (BSC Mainnet)**: `0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE`
- **Public BSC RPC**: `https://bsc-dataseed.binance.org/`

---

## 1. Concept & Strict Honesty Rules

1. **One Card Only**: CRYPTOSYM is **ONE single 3D Genesis card design** issued in **3,333 identical copies** (ERC-721 with a single shared `tokenURI`). There are **no trait layers, no variations, no rarity tiers, and no per-token generative art**. Never mention rarity or traits to the user.
2. **No Agent ID Gate**: Any wallet on BNB Smart Chain can mint and enter the lottery (both Binance Agentic Wallets via `baw` and standard EVM wallets).
3. **Web-First Deployment Check**: The website launches **before** the smart contract is deployed.
   - Always fetch `https://cryptosim.online/mint.json` before attempting any contract call.
   - If `liveStatus.deployed` is `false` or `contracts.mintContractAddress` is `null`, **STOP immediately** and report honestly:
     > `"Minting coming soon — contract not deployed yet."`
   - Never invent, guess, or substitute a placeholder contract address.
4. **Lottery Pool Honesty**:
   - The holder lottery pool is **around 70 BNB, to be distributed later**.
   - Never claim the 70 BNB pool is already funded unless verified on-chain, never invent a distribution date or draw method (both are `"coming later"`), and always clarify that holding more Genesis cards increases draw entries (`1 card held = 1 entry`) but **guarantees nothing**.

---

## 2. Contracts (Once Deployed)

Resolve addresses dynamically from `https://cryptosim.online/mint.json` (which mirrors `VITE_MINT_CONTRACT_ADDRESS` and `VITE_LOTTERY_CONTRACT_ADDRESS` once live):

- **`MINT_CONTRACT`**: `contracts.mintContractAddress` (`null` until deployed)
- **`LOTTERY_CONTRACT`**: `contracts.lotteryContractAddress` (if `null` while `MINT_CONTRACT` is set and `liveStatus.lotteryEntryLive` is `true`, the lottery module lives inside `MINT_CONTRACT`)
- **`CHAINLINK_BNB_USD`**: `0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE` (8 decimals)

---

## 3. Mandatory Read-First Checks (JSON-RPC `eth_call` on Chain 56)

Before building any `baw contract-call preview`, execute these read-only checks against `https://bsc-dataseed.binance.org/`:

### A. Supply & Wallet Mint Allowance (`MINT_CONTRACT`)
| Check | Signature | Selector | Purpose |
| :--- | :--- | :--- | :--- |
| Total Minted | `totalMinted()` *(fallback `totalSupply()`)* | `0xa2309ff8` *(`0x18160ddd`)* | Confirm `totalMinted < 3333`. Remaining = `3333 - totalMinted`. |
| Wallet Minted Count | `mintedCount(address)` | `0xfddcb5ea` | Check if caller already used their 1st free mint (`mintedCount == 0` means 1st card is free) and verify `mintedCount + quantity <= 10` (proposed max 10/wallet). |
| Current Card Balance | `balanceOf(address)` | `0x70a08231` | Number of Genesis cards currently held by the wallet (`1 card = 1 lottery entry` once registered). |
| Exact Mint Quote | `quote(address,uint256)` | `0x8f79306e` | Exact `msg.value` in wei required for `(wallet, quantity)`. |
| Unit Paid Mint Price | `mintPriceWei()` | `0xcb2c9722` | Per-card wei equivalent of `$0.20 in BNB` via Chainlink BNB/USD. |

**Pricing Formula Verification**:
- Fresh wallet (`mintedCount(wallet) == 0`):
  - `quantity = 1` -> `0 wei` (**FREE**, gas only).
  - `quantity = N` (`2 <= N <= 10`) -> `(N - 1) * $0.20 in BNB` (`1 free + (N - 1) paid`). Example: `mint(3)` = `2 * $0.20 = $0.40 in BNB`.
- Returning wallet (`mintedCount(wallet) >= 1`):
  - `quantity = N` -> `N * $0.20 in BNB`.

### B. Lottery Entries, Registration & Pool State (`LOTTERY_CONTRACT`)
| Check | Signature | Selector | Purpose |
| :--- | :--- | :--- | :--- |
| Total Registered Wallets | `totalEntries()` | `0x7fef036e` | Live count of wallets registered for the draw (each registered wallet's entries = its card balance). |
| Wallet Registered? | `entered(address)` | `0x17b299aa` | Returns `true` if wallet already paid the one-time `$0.10 in BNB` entry fee. Do **not** pay twice. |
| Wallet Entry Weight | `balanceOf(address)` | `0x70a08231` | Cards held by `<address>` — a registered wallet's entries equal its card balance (`1 card = 1 entry`). There is no `entriesOf()` on the real contract. |
| Exact Entry Fee | `lotteryPriceWei()` | `0x36cad1b4` | Exact `msg.value` in wei for `$0.10 in BNB` (one-time per wallet). |
| On-Chain Pool Balance | `eth_getBalance(LOTTERY_CONTRACT, "latest")` | JSON-RPC | Check actual contract BNB balance if user asks; remember target pool is *around 70 BNB, to be distributed later*. |

### C. Chainlink BNB/USD Reference Check (`0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE`)
- Call `latestRoundData()` (`0xfeaf968c`). `answer` has `8` decimals (`bnbUsd = Number(answer) / 1e8`).
- `$0.20 in wei` = `BigInt(Math.ceil((0.20 / bnbUsd) * 1e18))` (always prefer the contract's `quote(wallet, quantity)` on-chain return value so no rounding mismatch reverts).

---

## 4. Mint Flow (Single or Batch) via `baw` CLI

### Calldata Encoding
- Function: `mint(uint256 quantity)`
- Selector: `0xa0712d68`
- Argument: 32-byte hex-padded `quantity` (`1` to `10`).
  - `mint(1)` calldata: `0xa0712d680000000000000000000000000000000000000000000000000000000000000001`
  - `mint(3)` calldata: `0xa0712d680000000000000000000000000000000000000000000000000000000000000003`

### Step-by-Step `baw` Execution
1. **Ensure Agentic Wallet session is signed in** (with Developer Mode enabled in the Binance App):
   ```bash
   baw wallet sign-in
   ```
2. **Run Read-First Checks** (`totalMinted()`, `mintedCount(<WALLET>)`, `quote(<WALLET>, <QTY>)`) and confirm `<MINT_CONTRACT>` is deployed.
3. **Preview the contract call** (never skip preview):
   ```bash
   baw contract-call preview \
     --binanceChainId 56 \
     --from <YOUR_WALLET_ADDRESS> \
     --to <MINT_CONTRACT> \
     --value <QUOTED_MINT_WEI> \
     --inputData 0xa0712d680000000000000000000000000000000000000000000000000000000000000001 \
     --json
   ```
4. **Confirm with User**: Show the user the quantity of identical CRYPTOSYM Genesis cards being minted, exact BNB cost (`0` wei for 1st free mint, or quoted BNB for batch/paid mints), estimated gas, and `requestId`. Wait for explicit user approval.
5. **Execute the previewed request**:
   ```bash
   baw contract-call execute \
     --requestId <REQUEST_ID_FROM_PREVIEW> \
     --json
   ```
   *(If status returns `PENDING_CONFIRMATION`, ask the user to approve the prompt in the Binance App.)*

---

## 5. Lottery-Entry Flow via `baw` CLI

Entering the ~70 BNB lottery draw is **optional** and **one-time per wallet** (`$0.10 in BNB`). Once registered, every CRYPTOSYM Genesis card held by that wallet counts as **1 entry**.

### Calldata Encoding
- Function: `enterLottery()`
- Selector: `0xc1af5785` (no arguments; `inputData` is `0xc1af5785`).

### Step-by-Step `baw` Execution
1. **Run Read-First Checks**:
   - Confirm `entered(<YOUR_WALLET_ADDRESS>)` (`0x17b299aa`) is `false`. If `true`, stop — the wallet is already registered and all held Genesis cards automatically count as entries.
   - Confirm `balanceOf(<YOUR_WALLET_ADDRESS>)` (`0x70a08231`) is `>= 1` (mint at least one Genesis card first).
   - Read exact `ENTRY_FEE_WEI` from `lotteryPriceWei()` (`0x36cad1b4`, `~$0.10 in BNB`).
2. **Preview the lottery entry call**:
   ```bash
   baw contract-call preview \
     --binanceChainId 56 \
     --from <YOUR_WALLET_ADDRESS> \
     --to <LOTTERY_CONTRACT> \
     --value <ENTRY_FEE_WEI> \
     --inputData 0xc1af5785 \
     --json
   ```
3. **Confirm with User**: State the exact BNB fee (`~$0.10`), how many Genesis cards/entries the wallet holds, and remind them that the ~70 BNB pool distribution date and draw method are coming later with no guaranteed win. Wait for explicit approval.
4. **Execute the previewed request**:
   ```bash
   baw contract-call execute \
     --requestId <REQUEST_ID_FROM_PREVIEW> \
     --json
   ```
