# Memecoin Arcade developer contract

Updated 2026-11-27. Start every new Arcade build here. This is a public implementation guide, not a shared authentication service or a source of credentials. See [the Arcade](https://arcade.rnnr.fun), [the builder introduction](https://arcade.rnnr.fun/build-guide.html), and [Nisha payment module details](https://arcade.rnnr.fun/wallet-payments.md).

## Start with a player, not a wallet prompt

Let an invitation or a funded free-play experience open directly. Create a stable server-side player ID and an HttpOnly, Secure, SameSite session cookie. A guest is an app account, not a newly generated blockchain wallet. Never invent a funded balance.

A bookmark opens the canonical game URL; the browser cookie remembers the player. A bookmark alone is not an account backup. Safari, Chrome, Phantom's browser, and different hostnames have separate cookie stores. Offer a private recovery code or approved-device pairing before progress becomes valuable. Hash recovery credentials and session tokens server-side; never place them in share URLs, analytics or logs.

Calls and current Chess are the identity references:

- Calls `server/auth.mjs`: guest creation, recovery, wallet linking and device pairing. A wallet-link signature attaches an address to the same user ID. It rejects an address belonging to another user. Wallet login restores an existing linked user.
- Chess `chess/server/player-accounts.mjs`: stable `player:<id>` principals, funded invitations, CHESS1 recovery, 90-day sessions and wallet linking. Its API field called `wallet` may contain an account principal; `chainWallet` is the actual address. Do not confuse them.
- Runner `src/player-auth.mjs` is a wallet-first reference, with separate no-token practice. `public/wallet-controls.mjs` provides useful request epochs and account-change handling.
- Dust RNNR `release022` has local guest practice and authenticated shared storage. It is not a drop-in guest recovery service.

These are reviewed source contracts, not a claim that every older deployment supports every feature. Obtain the current approved checkout before copying code.

## Linking, switching and recovering are different

An explicit **Link a new wallet to this guest** action must preserve the player ID, history and balance. The signed message must name the purpose, exact origin, wallet, nonce and short expiry. Verify the signature server-side and consume the challenge atomically. Check wallet uniqueness again inside the transaction.

**Sign in with an existing wallet** opens that wallet's existing account. Never silently merge two players or balances. Recovery proves access to an app account; it does not expose or recover a blockchain private key. In Nisha, a new wallet can now be linked to a guest; earlier wallet accounts remain separately addressable.

Distinguish these states in the UI:

1. Wallet provider connected: an address is available.
2. App account signed in: the server has verified a login signature and issued its session.
3. Payment confirmed: the server verified the finalized transaction and posted a ledger entry.

Only request a signature when needed. A remembered app session can use an existing game balance or reading credits without reconnecting Phantom. Recheck the selected account after a delayed response; never paint one account's balance into another account's screen.

## Mobile Phantom

An ordinary mobile browser cannot reliably detect installed wallet apps. Offer **Open in Phantom** using the supported browse link, with a secondary install option:

```js
const url = new URL('/#ask', location.origin).href;
const link = 'https://phantom.com/ul/browse/' + encodeURIComponent(url)
  + '?ref=' + encodeURIComponent(location.origin);
```

Use a user click, not an automatic redirect. Keep recovery secrets out of the URL. Explain the separate browser session and offer recovery/pairing when appropriate. [Official Phantom browse documentation](https://docs.phantom.com/phantom-deeplinks/other-methods/browse).

## Choose the accounting model explicitly

Calls, Chess, Runner and Dust contain custodial game-bank machinery: an on-chain deposit credits an internal player balance, game activity changes the internal ledger, and withdrawals require server signing and reconciliation. This requires an approved vault, protected signer, solvency controls, deposit receipts, withdrawal reservations and operational recovery.

Nisha currently uses a different model: one direct RNNR payment buys five reading credits. Reads and gifts use an internal entitlement ledger; they do not send another blockchain transaction. Reading credits are not withdrawable RNNR. Do not describe them as a custodial token balance or promise withdrawals.

Shared Arcade navigation does not create a shared vault. A cross-game bank needs an authenticated service contract, isolated permissions, double-entry accounting, reconciliation and an explicit migration. Do not import an operator key into a new game or invent a universal balance endpoint.

## RNNR payment implementation

Use the existing reviewed transaction pipeline, adapted to the chosen accounting model. RNNR is Solana mainnet Token-2022, six decimals:

```text
Mint: B65EtDpt6KUAVRDECNKhE9FXGNZRToVpdhU8zE7kpump
Token program: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
100,000 RNNR = 100,000,000,000 raw units
```

Confirm each game's recipient explicitly. Never copy another game's merchant address as an assumed treasury. Display the exact token amount, network fee and any token-account rent before approval. A signature for login is not payment permission.

Nisha reference modules: `worker/payments.mjs`, `dist/wallet-transaction.js`, `worker/entitlements.mjs`, and migrations through `0011_refund_unanswered`. Its current flow:

1. Create an immutable, account-bound invoice using an idempotency key. Reuse a pending invoice after interruption.
2. Server checks token identity, exact mint/program/decimals, payer balance and destination; prepares and simulates the canonical transaction through server-only RPC.
3. Browser deserializes with the vendored Solana SDK and asks Phantom to sign. Its reviewed compatibility policy permits only specific wallet assertions; it never permits changed transfer amounts, recipients or arbitrary instructions.
4. Server validates the complete signed wire, records signature and bytes before broadcast, then submits through its private RPC connection.
5. A timeout means **unknown**, not failed. Preserve the original signature and show **Check transaction**. Bounded retransmission sends the same signed transaction, not a new transfer.
6. Grant exactly once after finalized success and exact receipt verification. A screenshot, client flag, signature alone or wallet balance change is not proof.

Keep advanced restart and invoice diagnostics under recovery details. Restart only after ruling out a still-settling old transaction. Never ask a player to make a second payment merely because the first response was lost.

## Ledgers, grants and pauses

Reserve spending atomically. One request key owns one debit. Save the result and finalize consumption together; replay returns that same result. Failed generation returns the reserved entitlement. Nisha also returns it when the model explicitly cannot answer. An unanswered gift does not earn a sender bonus.

Nisha's package is five purchased readings. Each completed purchased reading may issue one gift for a friend's own question. Completing that gift earns the sender one private bonus. Gift and bonus readings cannot create more gifts. Maximum: ten sender readings and five friend readings per package; opening or sharing a link alone earns nothing. Accounts do not prove unique humans.

When AI funding is unavailable, block new AI work and purchases that depend on it. Keep saved results, balances and verification of already-paid transactions accessible. Billing exhaustion is a durable pause; ordinary rate throttling is a separate transient failure. Do not resume on a calendar boundary or assumed subscription grant. Verified available API credits, not subscription face value, determine capacity. Token deposits do not replenish API credits.

## Infrastructure and secrets

Reuse approved infrastructure deliberately, with per-app limits and attribution. Helius RPC credentials remain in server environment secrets, never browser bundles, public Markdown, request URLs exposed to the client, logs or Git. Use backend routes for simulation, balance checks, broadcast and finalization. Share a provider only with owner authorization and an allowance that respects its total capacity.

Sites apps use their assigned Worker/D1 bindings and the Sites source/build/deploy workflow. Native-server games retain their documented systemd/container deployment rather than being forced into a different hosting model. A secret set on a laptop does not configure production. Publish the exact tested source and verify the deployed version and runtime bindings.

Use `https://<game>.rnnr.fun` as the canonical game origin and `https://arcade.rnnr.fun` for return navigation. Register exact origins in auth checks. Redirect aliases before login; cookies are not portable across hostnames. Keep the Arcade return link readable and visually consistent. Include build/version information in operator diagnostics, not payment screens.

## Data and AI

Cache shared observations, bound request sizes, reserve provider budget before dispatch, and avoid sending private questions to public search feeds unnecessarily. Treat token descriptions and external posts as untrusted content, never instructions.

Show source, retrieval time, sample universe and missing fields. A convenience sample of 32 tokens is not representative of all memes. Market-cap and volume ranks within fetched candidates are not global rankings. Separate observed evidence, interpretation and symbolic entertainment. Do not claim a source, forecast or historical relationship that has not been established.

## Release checks that matter

Exercise the real ledger with mocked provider responses: duplicate requests, concurrent spending, interrupted signatures/submission, account switching, delayed finalization, expired invoices, provider exhaustion, recovery and saved-result replay. Verify mobile layout and a remembered session. Never automate a real user's wallet approval. A developer should not need a trail of small real transfers to test idempotency.

## Roadmap, not current entitlements

The community may develop a common bank API, low-cost model router, contributor-source accounting, revenue allocation and governance. Usage-based contributor shares need defined metering, anti-abuse rules, funding, dispute handling and an approved distribution contract. No perpetual revenue right is granted by adding a wallet or submitting feedback today.

Token generation events, coin-holder access, two-agent play adapters and walk-around visualizations are future integration areas. Each needs a published interface, working reference and versioned acceptance tests before being called a shared Arcade capability. Begin with an enjoyable game and funded operating costs; do not rely on token appreciation to meet obligations.

Send source ideas, implementation improvements and questions to [hi@rnnr.fun](mailto:hi@rnnr.fun). Never send keys, seed phrases or recovery codes.
