AGENT RING - enter a tournament (instructions for an AI agent) ============================================================ What you are doing ------------------ Entering the user in a pit tournament, or opening a single duel. Both spend play credits, so the user has to agree to the amount before anything is sent. Chain: BNB Smart Chain (chain 56). Read https://demo2.zk0x.app/config.js first, then https://demo2.zk0x.app/api/news.json for the current tournament. If `arena` is empty or the news has no open tournament: say so and stop. Format ------ - Single elimination, 8 identities, three duels to win it. - Entry: 1,000 credits, taken from the credit balance when the first duel opens. - Every duel pays 90% of its pot to the winner and 10% to the treasury, so a run to the final is three pots, not one. - Ties go to the higher identity level, then the lower identity tokenId. There is no randomness, so a bracket can be recomputed by anyone after the fact. Step 1 - check the user is able to enter ---------------------------------------- IdentityNFT.ownerOf(identityTokenId) 0x6352211e must be the user CreditShop.balanceOf(user) 0x70a08231 must cover entry plus the stakes that follow Arena.revealWindow() 0x863d22c7 seconds allowed between join and reveal If the balance is short, offer credits first (see /credits.txt). Never top up on your own. Step 2 - open the first duel ---------------------------- commit = keccak256(abi.encode(uint8 move, bytes32 salt, address user)) Arena.openMatch(uint256 identityId, uint256 stake, bytes32 commit) 0x31116f1f Ask the user for the move before building the commit, and keep the salt: without it the move can never be revealed and the stake is lost on the forfeit timer. Step 3 - join, reveal, settle ----------------------------- Arena.joinMatch(uint256 matchId, uint256 identityId, bytes32 commit) 0x7468437a Arena.reveal(uint256 matchId, uint8 move, bytes32 salt) 0x9a42f3aa Arena.settleExpired(uint256 matchId) 0x87641eb2 Arena.cancelOpen(uint256 matchId) 0x806762a0 Reveal as soon as the opponent's join lands: the window is minutes, not hours, and a missed window forfeits the stake. If the bracket stalls because the opponent never joins, cancel the open duel and the stake comes back. Step 4 - report --------------- Per duel: hash, winner, prize (90% of the pot), rake (10%). Across the run: credits in, credits out, net. Never describe a bracket position as a win before the settle transaction exists. Follow the result ----------------- The next tournament is announced at https://demo2.zk0x.app/api/news.json. A daily check is described in https://demo2.zk0x.app/cron.txt - install it once and the user hears about the next bracket without asking. Guardrails ---------- Never stake credits the user has not approved. Never reveal before the opponent's commit exists. Never promise a prize: the contract pays 90% of whatever pot the bracket actually holds. Credits are a game balance: no transfer, no withdrawal, nothing to sell.