# KAGEVEIL Genesis — Agent Skill (v1.3)
> Machine-readable instructions for autonomous AI agents and Binance Agentic Wallet users.
> If anything here conflicts with on-chain contract state, the chain wins.

name: kageveil-genesis
version: 1.3.0
project: KAGEVEIL Genesis
symbol: KAGE
standard: ERC-721 (ERC721A), ERC-2981 royalties
homepage: https://www.kageveil.xyz

## 0. Read first: common mistakes
- There is no mint(), mint(uint256), freeMint(), claim() or PRICE() on this contract. Calling them reverts with empty data for everyone. That is a wrong selector, not a frozen or paused mint.
- The only mint functions are mintNormal(bytes32 agentIdHash, bytes signature) (free, value 0), mintElite(uint256 quantity) and mintPack(uint256 packs) (both payable).
- A mintNormal simulation with an empty or made-up signature reverts with 0xfce698f7. That is OpenZeppelin's ECDSAInvalidSignatureLength(uint256), raised before the contract's own BadSignature check. It does not mean the gate is broken. Get a real signature first (section 5).
- To check whether minting is live, read mintOpen(), mintClosed() and totalSupply(), or GET https://www.kageveil.xyz/api/mint/status.

## 1. Network
- Chain: BNB Smart Chain mainnet, chainId 56 (0x38). No testnet deployment.
- Explorer: https://bscscan.com/address/0xF79860f419be7B604d909e254785400D9EDBD9d0 (source verified)
- Reject any chain other than 56.

## 2. Contract registry
```json
{
  "kageveilGenesis": "0xF79860f419be7B604d909e254785400D9EDBD9d0",
  "agentIdRegistry": "0x60B9262456dE011F7d15a54CdD8c48bAaa8B022F",
  "agentSigner": "0xAC261122620f895cfdE7A0779Ac938D9Aff6F2DC",
  "freeClaimSigner": "https://bccfyfcafdpsxvjidjlz.supabase.co/functions/v1/kageveil-signer",
  "authoritativePhaseSource": "mintOpen() and mintClosed() on the contract"
}
```
Never send BNB to any other address claiming to be Kageveil.

## 3. Supply and pricing
- Max supply 9,999 = 3,333 Normal + 6,666 Elite. Token IDs start at 1 and are shared by both pools in mint order; use isElite(tokenId) to tell them apart.
- Normal: free (gas only). One claim per .ai Agent ID handle and one per wallet. Transferring the handle does not reopen its claim.
- Elite single: elitePrice() (0.0015 BNB). mintElite(quantity), value = elitePrice * quantity exactly. 3,802 public singles.
- Elite Pack: packPrice() (0.0054 BNB) for 4 cards. mintPack(packs), value = packPrice * packs exactly. 666 packs.
- Cap: 8 directly purchased Elite cards per wallet (eliteCardsOf), singles and packs combined. Transfers do not reset it; it is not a holding limit, and owner reserve airdrops are exempt. Free Normal claims do not count toward it.
- 200 Elite cards stay in the owner reserve (airdropElite) and are not sold. The quest raffle gives 5 of them each day for 7 days (35).
- Normal rarity: Common 2,500 / Uncommon 666 / Rare 167. Elite: Uncommon 4,666 / Rare 1,800 / Legendary 200.
- Prices are read from the contract; always read elitePrice() and packPrice() before sending value.

## 4. Read-only checks (no gas)
| Function | Purpose |
| --- | --- |
| mintOpen(), mintClosed() | Mint phase |
| totalSupply(), normalMinted(), eliteMinted(), eliteSingleMinted(), packsMinted(), reserveMinted() | Counters |
| elitePrice(), packPrice() | Prices in wei |
| eliteCardsOf(address) | Elite cards this wallet has minted (cap 8) |
| agentUsed(bytes32 agentIdHash), walletUsedNormal(address) | Free-claim status |
| isElite(tokenId), hasBetaAccess(tokenId) | Box type and game beta flag (Elite cards) |
| revealed(), seed() | Reveal state |
| cardOf(tokenId) | After reveal: elite, rarity, house, atk, def, spd, chakra, jutsu1, jutsu2 |
| tokenURI(tokenId) | Sealed box metadata until reveal, then per-token metadata |

## 5. Free mint (Normal Box)
1. agentIdHash = keccak256(utf8(handle without ".ai", lowercase)). Example: smirk.ai -> keccak256("smirk").
2. Check the registry: ownerOf(uint256(agentIdHash)) on 0x60B9…022F must equal your wallet.
3. Check mintOpen() is true, agentUsed(agentIdHash) is false, walletUsedNormal(wallet) is false.
4. POST to the freeClaimSigner (or https://www.kageveil.xyz/api/mint/sign, same body and answers): {"handle":"yourname.ai","wallet":"0xYourWallet"}.
   200 returns {agentIdHash, signature}. Errors: 403 wallet_does_not_own_handle, 404 handle_not_registered,
   409 mint_not_open | handle_already_minted | wallet_already_minted.
5. From that same wallet, call mintNormal(agentIdHash, signature) with value 0. The signature only works for the wallet it was issued to.

Example request:
```bash
curl -s -X POST https://www.kageveil.xyz/api/mint/sign \
  -H "Content-Type: application/json" \
  -d '{"handle":"yourname.ai","wallet":"0xYourWallet"}'
```
A real free mint through this flow (token #45, value 0, method 0x51d282fb = mintNormal):
https://bscscan.com/tx/0x3ad8b080989ba51776303bae35475d0ceebae7e57e7a7b25803bff4a3b8aa2ee

## 6. Elite mint
1. Check mintOpen() and that eliteCardsOf(wallet) + cards <= 8.
2. mintElite(quantity) with value = elitePrice() * quantity, or mintPack(packs) with value = packPrice() * packs.
3. A wrong value reverts (WrongPrice). Over the cap reverts (WalletCap).

## Elite referral
- Link: https://www.kageveil.xyz/mint?ref=<checksummed wallet>.
- 1 free Elite box per 3 referred Elite cards. mintElite counts as its quantity (a single mint is 1 card). mintPack counts as 4 cards.
- Max 10 boxes per referrer. The pool is 100 boxes.
- Only mintElite and mintPack count. Free Normal mints do not.
- A referrer cannot refer themselves. The buyer's first referrer is kept.
- The referrer must hold at least 1 Kageveil NFT to be paid.
- Recording a referral does not send an airdrop. Payment is a later owner action. This site does not send referral boxes.

## 7. Reveal
- The owner must permanently close minting, fund the NFT contract’s own BNB balance, and request one Chainlink VRF v2.5 seed for the whole collection. The request is manual, not automatic.
- Rarity and House come from a seeded permutation over the fixed inventories, so the counts above are exact. Once the current request’s seed is accepted on-chain, the reveal is final. Before acceptance the owner can reset the pending request and request again; Chainlink advises against that capability.
- Stats and jutsu are set at reveal and are not used for any rewards.
- The same token ID changes from sealed box to revealed card. No new NFT is created.

- Metadata remains owner-updatable via setBoxURI and setBaseURI, including after reveal. Approved assets and hashes: https://www.kageveil.xyz/metadata/genesis-v1/manifest.json. The approved Genesis v1 art is pinned on public IPFS; verified CID and hashes: https://www.kageveil.xyz/metadata/genesis-v1/ipfs.json.
- All sealed tokens currently return the same box.json URL. Its image shows both cases; use isElite(tokenId), not the shared picture, to identify a token’s actual box type.

- Gameplay is coming soon. https://www.kageveil.xyz/play presents an art-direction teaser, not a playable build. The First Duel prototype is limited to local development. The full RPG and holder beta remain in development; no release date is announced.

## 8. Safety
- The site and this skill never ask for a seed phrase or private key.
- Only sign transactions to 0xF79860f419be7B604d909e254785400D9EDBD9d0 on chain 56.

## 9. Errors you may see
WrongPrice (value is not price x quantity), WalletCap (over 8 Elite cards), SoldOut, MintNotOpen,
AgentAlreadyMinted (this Agent ID or this wallet already claimed), BadSignature (signature was issued to another wallet).
Empty revert data: you called a function this contract does not have (see section 0). 0xfce698f7: the signature is empty or the wrong length (see section 0).

## 10. Honesty for agents
- Always simulate first and show the user the contract, method, value and gas before asking for approval.
- Never describe a card's rarity before the reveal. Every box is sealed until then.
- Kageveil is independent and is not affiliated with or endorsed by Binance.
