xsolana

v0.29.14
io.github.XGamesFun/solana-kit Checked 2 hours ago Published 2 days ago

Design, 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…

ParameterTypeDescription
partstringOne 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.…

ParameterTypeDescription
fitstringOnly ideas with this fit.
limitintegerHow many of each kind (default 6).
namestringAn example’s name, to get its whole spec.
querystringWhat 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…

ParameterTypeDescription
examplestringA worked example’s name (stud-farm, nft-raffle, …).
filestringThe spec's file, relative to the project folder (default: xsolana.json, when it exists).
specobjectThe 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:…

ParameterTypeDescription
examplestringA worked example’s name (stud-farm, nft-raffle, …).
filestringThe spec's file, relative to the project folder (default: xsolana.json, when it exists).
jsonbooleanAlso return every row.
scenarioobjectWhat to assume in place of the spec’s scenario.
specobjectThe 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.

ParameterTypeDescription
examplestringA worked example’s name (stud-farm, nft-raffle, …).
filestringThe spec's file, relative to the project folder (default: xsolana.json, when it exists).
specobjectThe 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.

ParameterTypeDescription
examplestringA worked example’s name (stud-farm, nft-raffle, …).
filestringThe spec's file, relative to the project folder (default: xsolana.json, when it exists).
specobjectThe 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…

ParameterTypeDescription
examplestringA worked example’s name (stud-farm, nft-raffle, …).
filestringThe spec's file, relative to the project folder (default: xsolana.json, when it exists).
specobjectThe 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…

ParameterTypeDescription
requirements *arrayWhat the person wants, each a requirement the tools can test.
examplestringA worked example’s name (stud-farm, nft-raffle, …).
filestringThe spec's file, relative to the project folder (default: xsolana.json, when it exists).
specobjectThe spec itself (version 2). Wins over file and example.
topintegerHow 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.

ParameterTypeDescription
spec *objectThe spec itself (version 2). Wins over file and example.
filestringThe 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…

ParameterTypeDescription
examplestringA worked example’s name (stud-farm, nft-raffle, …).
filestringThe spec's file, relative to the project folder (default: xsolana.json, when it exists).
specobjectThe 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.

ParameterTypeDescription
filestringThe spec's file, relative to the project folder (default: xsolana.json, when it exists).
specobjectThe 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…

ParameterTypeDescription
mint *stringThe token’s mint address.
keystringWhat the spec will call it (default: its ticker, in the letters a key takes).
projectstringThe 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.