xsolana
v0.29.14Design, check, simulate and review game economies for Solana: a JSON spec, no contract to write.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
xsolana_guide What an economy can be made of
Read this first whenever someone wants a web3 economy, game economy, token economy, NFT mechanic or onchain reward system: a shop, loot boxes or packs, gacha, a lottery or raffle, an auction (highest bid wins, the outbid refunded at once), staking or a farm, crafting or merging, seasons and emissions, a contest players back a side in, quests and airdrops, holder-gated drops, using NFTs of any other collection in a game. loot is ONE shared Solana program (on devnet, and on mainnet when the spec says "network": "mainnet"; not independently audited): the economy is a JSON spec, not a new smart co…
| Parameter | Type | Description |
|---|---|---|
part | string | One part, with its fields and nested shapes, or one topic (writing, cheating, asks, cannot). |
xsolana_examples Find a worked economy to start from
Find an economy to start from. With `query` (the person’s own words, as they said them), returns the closest worked examples (whole specs that check and go live in the tests), the closest of 112 kinds of economy rated by hand against an earlier loot (great / some / a-lot / cannot, with what carries it or what is missing), and what loot can’t do exactly in the ask, each with the nearest versions it can. Call it again with the words of any part that looks impossible: the answer is a nearest version to offer, not a dead end. With `name`, returns that example’s whole spec to copy and change.…
| Parameter | Type | Description |
|---|---|---|
fit | string | Only ideas with this fit. |
limit | integer | How many of each kind (default 6). |
name | string | An example’s name, to get its whole spec. |
query | string | What the person wants, in a few words. |
xsolana_check Check an economy spec
Check an economy spec: refusals (each with a code, what it means and its fix) stop it from going live; warnings are what the person must hear (chance that pays money, revenue paid to stakers, an unfunded prize, a grant without limits, a mint’s powers, a time far off with its date in words, a token a player can hold a payment up in, a box longer than one answer of the oracle’s holds). The program refuses only what it must: much of what a project sets up is taken and warned of, never refused, so each warning goes to the person. Run it after every change, and check before you describe: before…
| Parameter | Type | Description |
|---|---|---|
example | string | A worked example’s name (stud-farm, nft-raffle, …). |
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
spec | object | The spec itself (version 2). Wins over file and example. |
xsolana_simulate Simulate where the money goes
The quick simulation (expected values from the spec, instant): what each box, ticket and craft gives back against its price, what the game keeps, each pool’s money in and out per day and whether it runs dry, settles or grows, farm rewards per unit staked, what players, the treasury and the platform get each day; a box’s chances with its odds rules at their most, what a box that gives nothing for a miss misses as its outcomes run out, what a ticket weighs in a lottery weighed by time, and what places get from a pool that starts short. `scenario` overrides the spec’s own ({"perDay": {"box:…
| Parameter | Type | Description |
|---|---|---|
example | string | A worked example’s name (stud-farm, nft-raffle, …). |
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
json | boolean | Also return every row. |
scenario | object | What to assume in place of the spec’s scenario. |
spec | object | The spec itself (version 2). Wins over file and example. |
xsolana_cost Price going live and each action
What going live costs (each account’s rent, the program’s fees, network fees, the seeds, the transactions it takes) and what each action costs whoever signs it while it runs.
| Parameter | Type | Description |
|---|---|---|
example | string | A worked example’s name (stud-farm, nft-raffle, …). |
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
spec | object | The spec itself (version 2). Wins over file and example. |
xsolana_explain Explain an economy in plain words
The economy in plain words for the person: what players do and what it costs and is worth, how the pools fill and drain, what runs by itself, what the authority must sign, what going live costs, and what is flagged for the law. Tell them the essentials in a few lines, from this text.
| Parameter | Type | Description |
|---|---|---|
example | string | A worked example’s name (stud-farm, nft-raffle, …). |
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
spec | object | The spec itself (version 2). Wins over file and example. |
xsolana_review Review an economy as a cheater would
Review an economy the way a cheater reads it, before it goes live (not a validity check: xsolana_check is that). For every route that pays or gives value it says who can trigger it, what the program enforces, what it trusts off the chain, and the most one cheater gets; then findings with stable ids and a severity; then the trade-off to show the person: for each grant paid on vouchers, whether its server decides, replays or only bounds the result (its "trust"), what a cheater gets at that level, and what the next level costs to build. Fix every high finding, declare "trust" honestly on every vo…
| Parameter | Type | Description |
|---|---|---|
example | string | A worked example’s name (stud-farm, nft-raffle, …). |
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
spec | object | The spec itself (version 2). Wins over file and example. |
xsolana_design From what a person wants to the specs that do it
From what the person wants to the specs that do it, when no single part does it all or their wants pull against each other. Write each want as a requirement naming its route (the key of the lottery, item, grant, farm or contest it is about; its family follows from that): a draw ("pay-in" {currencies: [{token, amount}]}, "burn", "refund-as-paid", "free-entry" {grant, perPerson, spendable}, "one-approval", "one-draw", "one-token", "first-reward-no-sol"); a sale of an item ("pay-in", "fixed-price", "instant", "fair-scarce" {perPerson, list}, "one-approval"); a reward, a grant ("per-person" {claim…
| Parameter | Type | Description |
|---|---|---|
requirements * | array | What the person wants, each a requirement the tools can test. |
example | string | A worked example’s name (stud-farm, nft-raffle, …). |
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
spec | object | The spec itself (version 2). Wins over file and example. |
top | integer | How many designs to answer (3 by default). |
xsolana_save Save a checked spec in the project
Save a spec into the project (default xsolana.json), only if it checks. Saving is building, a draft too: a choice xsolana_design left to the person, and each question xsolana_check or xsolana_design has for them, is put to them before this, not after. A file that is already live keeps its program numbers and its live section. Never put a key in it: the checker refuses the forms it knows (a key in base58, in hex or as a keypair file’s bytes, a seed phrase, a keyed RPC link), and no check finds every way to write one.
| Parameter | Type | Description |
|---|---|---|
spec * | object | The spec itself (version 2). Wins over file and example. |
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
xsolana_publish The steps to go live (sends nothing)
When the person says to put it live: returns what going live does (every step, in order, and its cost) and the commands that do it (each starts npx -y @xgamesfun/solana@0.29.14 for this exact version: give them as they are). Going live is signed by a key file on the person’s own machine: `keygen` makes one for the project (it prints the address, never the key), and `approve … --keypair <file>` prints everything that would be sent and sends nothing until it is run again with the code it printed, which you do only after the person has read that printout and said yes. A live economy is change…
| Parameter | Type | Description |
|---|---|---|
example | string | A worked example’s name (stud-farm, nft-raffle, …). |
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
spec | object | The spec itself (version 2). Wins over file and example. |
xsolana_status Read a live economy from the chain
A live economy as it is on chain: the project, every pool’s balance, every record the spec names (found or missing). Reads the economy’s own cluster: devnet through its public RPC (or XSOLANA_RPC_URL), mainnet through XSOLANA_RPC_URL, which must then name a mainnet RPC.
| Parameter | Type | Description |
|---|---|---|
file | string | The spec's file, relative to the project folder (default: xsolana.json, when it exists). |
spec | object | The spec itself (version 2). Wins over file and example. |
xsolana_token Read a token made elsewhere
A token made elsewhere, as the chain has it, for an economy that uses it: give its mint’s address and get its ready `tokens` entry (`source: "existing"`) with its name, ticker, decimals and token program, and `powers` filled in: what the mint’s own keys can do (mint more, freeze, a transfer fee, a transfer hook, a permanent delegate, a pause…), in words too. Use it instead of asking the person to look the mint up. Reads the cluster of the economy in this folder (devnet unless its xsolana.json says "network": "mainnet"): devnet through its public RPC (or XSOLANA_RPC_URL), mainnet through…
| Parameter | Type | Description |
|---|---|---|
mint * | string | The token’s mint address. |
key | string | What the spec will call it (default: its ticker, in the letters a key takes). |
project | string | The loot project’s address, when the token is one the project is to mint on a mint of its own: its mint authority then reads as the project’s, or as not handed over yet. |
xsolana_client The program and its calls, for an app
How an app (a game, a site, a bot) uses a live economy: the program’s address and cluster, the npm package and IDL, and the calls a page makes with the player’s own wallet (open a box, buy, stake, craft, enter, claim). Use this instead of writing chain code from memory.