Skip to content
⌘K

Build a game

First game in a weekend

Build a web game with items, trophies and an in-game sell and buy sheet, with gas paid for players, starting from npm create rare-game.

The goal is a web game (HTML5, or a Godot or Unity web export) where players earn items and trophies, see their inventory, and sell or buy in the game, built by one developer over a weekend. This page follows the path and says which step needs what.

Some steps depend on pieces that are not live yet: the rare_items contract, the Studio game workspace, and game gas budgets. Each step below says so. The code you write does not change when they land.

Friday evening: set up the game record

About an hour, all in the browser, on testnet.

  1. Get an API key

    Sign in at rare.market/developers with any Sui wallet and create a key. See Authentication. You only need it for server-side ownership checks.

  2. Create the game

    In Studio, choose New game and enter a slug, a name, art and the play URL. The slug is the join key across items, trophies and the Store.

  3. Make the game key

    Studio generates an ed25519 key in your browser and downloads it once. The private key never leaves your machine. Only the public key goes on chain. Keep it out of git. See Voucher signing.

  4. Create the item class

    Two wallet transactions, about 0.1 SUI of testnet gas: publish the marker package (the same flow the launchpad uses), then create the class with a 5% royalty, locking on, and your game key as issuer, then add one kind for each item (for example Sword, Shield, Hat). Note the Class object id.

  5. Create the trophies

    One transaction creates the game with a web:<slug> identifier, sets your game key as its issuer, adds each trophy and sets the platinum. Note the Registry and Game object ids. See Trophies for studios.

Saturday: the game

  1. Scaffold it

    Shell
    npm create rare-game my-game -- --class-id 0x... --registry-id 0x... --trophy-game-id 0x...
    cd my-game
    npm install
    cp .env.example .env

    Put the game key in RARE_GAME_KEY and the same ids in .env. The ids are optional at first: the game runs without them and the server says which one is missing.

  2. Run it

    Shell
    npm run dev

    The game is on http://localhost:5173 and the voucher server on port 8787. Vite proxies /api to the server.

  3. Open it in Rare Launcher

    Shell
    rare-launcher --dev-game http://localhost:5173

    On a SuiPlay, add it with + Web game and the same URL. The launcher gives it the controller mapping, the keyboard and the wallet. See Testing in Rare OS.

What the template does

In the gameCodeWhat happens
Walk into a chestPOST /api/loot, then rare.claim(voucher)The server rolls a drop and signs a voucher for this player. The player confirms a one-line sheet and the item lands in their kiosk, locked, with gas paid.
Open a milestonePOST /api/trophies, then rare.claim(voucher) for eachThe server hands out each trophy the player has earned, once.
Inventory screenrare.inventory()The player's items from this game, with best offer and last sale.
Sell buttonrare.sell({ itemId })Rare's sell sheet opens over the game.
Buy buttonrare.buy({ collection })The buy sheet opens for the cheapest listing.
Trophies screenrare.open({ view: "trophies" })The launcher's trophy list for this game.

The files you will edit:

FileWhat it is
src/rare.tsEvery call the game makes to Rare, in one place.
server/game.mjsWhat drops, and which trophies are earned. Vouchers are made only here.
server/app.mjsThe HTTP handlers with per-player and per-address rate limits.
public/rare.jsonThe manifest that npm run check validates.

The template tracks progress in memory and trusts the client to say a chest was opened, with a 3 second gap and an hourly cap per player as a brake. In your game, make the server decide what a player earned from what actually happened, and sign a voucher only for that. A voucher is a mint, so treat the endpoint that makes one like a payment endpoint.

Sunday: ship

  1. Check the build

    Shell
    npm run build
    npm run check

    See Check your game. Fix every failure. Warnings for the placeholder URL and empty ids go away as you fill public/rare.json.

  2. Repeat the Friday steps on mainnet

    The same Studio clicks, about 0.1 SUI of real gas. Replace the ids in .env and public/rare.json, set the network to mainnet in src/rare.ts (Rare.connect({ network: "mainnet" })), and deploy your server.

  3. Pay for players' gas

    Take the starter grant for a verified mainnet game, or send SUI to the game's budget. See Gas sponsoring.

  4. Set the status to beta

    The game appears in the launcher's Sui Games, on rare.market/games/<slug>, in the overlay with the player's items, offers and trophies, and its items trade on every Sui marketplace. See Get your game listed.

Native games

A Unity, Godot or Unreal game on Linux or Windows follows the same path with a thin engine wrapper over the Rare Local API in place of the browser. Off the device, players use the rare.market web transport. Engine wrappers are not released yet.

--
TPS:--