@xgamesfun/solana 0.26.2 → 0.26.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/bin/xsolana.mjs +8 -1
- package/examples/blind-forge.json +2 -1
- package/examples/community-coin.json +100 -0
- package/js/approve/live-check.mjs +217 -3
- package/js/approve/page.html +1 -1
- package/js/approve/page.js +41 -11
- package/js/approve/server.mjs +236 -41
- package/js/chain/metadata.js +92 -0
- package/js/chain/mint.js +55 -0
- package/js/chain/token2022.js +89 -0
- package/js/economy/check.mjs +43 -5
- package/js/economy/cost.mjs +6 -5
- package/js/economy/explain.mjs +4 -3
- package/js/economy/guide.mjs +2 -2
- package/js/economy/legal.mjs +2 -0
- package/js/economy/live.mjs +27 -7
- package/js/economy/model.mjs +13 -2
- package/js/economy/plan.mjs +84 -27
- package/js/economy/schema.json +7 -1
- package/js/mcp/tools.mjs +174 -11
- package/package.json +1 -1
- package/release.json +1 -1
- package/skills/xsolana-economy/SKILL.md +27 -5
- package/skills/xsolana-economy/references/sentence-to-spec.md +1 -1
- package/skills/xsolana-economy/references/telling-the-person.md +7 -3
- package/types/chain/metadata.d.ts +45 -0
- package/types/chain/mint.d.ts +29 -0
- package/types/chain/token2022.d.ts +38 -0
- package/types/economy/cost.d.mts +11 -3
- package/types/economy/legal.d.mts +1 -0
- package/types/economy/live.d.mts +29 -5
- package/types/economy/model.d.mts +6 -0
- package/types/economy/plan.d.mts +22 -5
- package/types/mcp/server.d.mts +53 -1
- package/types/mcp/tools.d.mts +111 -4
package/js/mcp/tools.mjs
CHANGED
|
@@ -5,14 +5,18 @@
|
|
|
5
5
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
6
6
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
7
7
|
import path from 'node:path';
|
|
8
|
+
import { addressBytes } from '../chain/base58.js';
|
|
9
|
+
import { metadataAddress } from '../chain/metadata.js';
|
|
10
|
+
import { parseMint, tokenEntry } from '../chain/mint.js';
|
|
8
11
|
import { checkCluster, notMainnet, rpcClient } from '../chain/rpc.js';
|
|
12
|
+
import { mintState } from '../chain/token2022.js';
|
|
9
13
|
import { decodeAny } from '../client/accounts.js';
|
|
10
14
|
import { IDL } from '../client/ix.js';
|
|
11
15
|
import { LOOT_PROGRAM, pda } from '../client/pda.js';
|
|
12
16
|
import { check, describe } from '../economy/check.mjs';
|
|
13
17
|
import { legalFlags } from '../economy/legal.mjs';
|
|
14
18
|
import { cost, explainCost } from '../economy/cost.mjs';
|
|
15
|
-
import { changedParts } from '../economy/live.mjs';
|
|
19
|
+
import { changedParts, renamesNote } from '../economy/live.mjs';
|
|
16
20
|
import { example, examples, ideas, search, partsUsed } from '../economy/examples.mjs';
|
|
17
21
|
import { explainEconomy } from '../economy/explain.mjs';
|
|
18
22
|
import { describeReview, review } from '../economy/review.mjs';
|
|
@@ -82,6 +86,7 @@ export const REMOTE_TOOLS = new Set([
|
|
|
82
86
|
'xsolana_explain',
|
|
83
87
|
'xsolana_review',
|
|
84
88
|
'xsolana_status',
|
|
89
|
+
'xsolana_token',
|
|
85
90
|
'xsolana_client',
|
|
86
91
|
]);
|
|
87
92
|
|
|
@@ -242,10 +247,11 @@ function flagsToTell(economy, now) {
|
|
|
242
247
|
* what can't change or was taken out.
|
|
243
248
|
*/
|
|
244
249
|
function liveChange(economy) {
|
|
245
|
-
if (!economy.live?.project || !economy.live?.published) return { scope: {}, notes: '', settings: [] };
|
|
246
|
-
const { only, fixed, removed, settings } = changedParts(economy);
|
|
250
|
+
if (!economy.live?.project || !economy.live?.published) return { scope: {}, notes: '', settings: [], changes: 0 };
|
|
251
|
+
const { only, fixed, removed, settings, renames } = changedParts(economy);
|
|
247
252
|
const notes = [
|
|
248
253
|
settings.length ? `\n${settingsNote(settings, economy.live)}` : '',
|
|
254
|
+
renames.length ? `\n${renamesNote(renames)}` : '',
|
|
249
255
|
fixed.length
|
|
250
256
|
? `\nThese can't change once live, and stay as they were: ${fixed.join(', ')} (a farm, an auction or a pool's token).`
|
|
251
257
|
: '',
|
|
@@ -253,7 +259,8 @@ function liveChange(economy) {
|
|
|
253
259
|
? `\nTaken out of the spec but still on chain: ${removed.join(', ')}. To stop one, keep it and set "active": false.`
|
|
254
260
|
: '',
|
|
255
261
|
].join('');
|
|
256
|
-
|
|
262
|
+
// (`changes`: whether anything is to be published at all: a part, or a token's name)
|
|
263
|
+
return { scope: { only, live: economy.live, renames }, notes, settings, changes: only.size + renames.length };
|
|
257
264
|
}
|
|
258
265
|
|
|
259
266
|
/** In words: the spec changes the project's own settings, which publishing never writes. */
|
|
@@ -423,11 +430,20 @@ export const tools = [
|
|
|
423
430
|
const c = cost(economy, { now: nowOf(ctx), ...change.scope });
|
|
424
431
|
if (!c.ok) return refused(c, from);
|
|
425
432
|
const head = change.scope.live
|
|
426
|
-
? change.
|
|
427
|
-
? `This economy is live: this prices only the change (${[...change.scope.only].join(', ')}).\n`
|
|
433
|
+
? change.changes
|
|
434
|
+
? `This economy is live: this prices only the change (${[...change.scope.only, ...change.scope.renames.map(key => `the name of ${key}`)].join(', ')}).\n`
|
|
428
435
|
: 'This economy is live and nothing has changed since it went live: publishing costs nothing.\n'
|
|
429
436
|
: '';
|
|
430
|
-
|
|
437
|
+
// (a name's price is a transaction's, if it is sent at all: only approving reads the token's record)
|
|
438
|
+
const names = change.scope.renames?.length ? `\n${renamesNote(change.scope.renames)}` : '';
|
|
439
|
+
return {
|
|
440
|
+
ok: true,
|
|
441
|
+
from,
|
|
442
|
+
setup: c.setup,
|
|
443
|
+
actions: c.actions,
|
|
444
|
+
fees: c.fees,
|
|
445
|
+
text: head + explainCost(c) + names + footer,
|
|
446
|
+
};
|
|
431
447
|
},
|
|
432
448
|
},
|
|
433
449
|
{
|
|
@@ -554,7 +570,7 @@ export const tools = [
|
|
|
554
570
|
async handler(input, ctx) {
|
|
555
571
|
const { economy, from, file } = await load(input, ctx);
|
|
556
572
|
const change = liveChange(economy);
|
|
557
|
-
if (change.scope.live && !change.
|
|
573
|
+
if (change.scope.live && !change.changes && change.settings.length)
|
|
558
574
|
return {
|
|
559
575
|
ok: false,
|
|
560
576
|
transactions: 0,
|
|
@@ -562,7 +578,7 @@ export const tools = [
|
|
|
562
578
|
steps: [],
|
|
563
579
|
text: `${from} is live, and its parts are as they are on chain. ${settingsNote(change.settings, economy.live)}${footer}`,
|
|
564
580
|
};
|
|
565
|
-
if (change.scope.live && !change.
|
|
581
|
+
if (change.scope.live && !change.changes)
|
|
566
582
|
return {
|
|
567
583
|
ok: true,
|
|
568
584
|
transactions: 0,
|
|
@@ -573,7 +589,15 @@ export const tools = [
|
|
|
573
589
|
const p = plan(economy, { now: nowOf(ctx), ...change.scope });
|
|
574
590
|
if (!p.ok) return refused(p, from);
|
|
575
591
|
const c = cost(economy, { now: nowOf(ctx), ...change.scope });
|
|
576
|
-
|
|
592
|
+
// A token's new name is listed as the file has it: whether it is sent is the chain's to say, as approving reads it.
|
|
593
|
+
const steps = p.transactions.flatMap(t =>
|
|
594
|
+
t.steps.map(s =>
|
|
595
|
+
s.id.startsWith('name:')
|
|
596
|
+
? `${s.says} (sent only if the token has a name record its owner can still change, read when approving)`
|
|
597
|
+
: s.says,
|
|
598
|
+
),
|
|
599
|
+
);
|
|
600
|
+
const renaming = Boolean(change.scope.renames?.length);
|
|
577
601
|
// the file as the approve command names it, relative to the project folder (projectFile's), and plain (plainName)
|
|
578
602
|
const target = file ? path.relative(realPath(path.resolve(cwdOf(ctx))), file) || DEFAULT_FILE : DEFAULT_FILE;
|
|
579
603
|
if (plainName(target) === null)
|
|
@@ -587,7 +611,7 @@ export const tools = [
|
|
|
587
611
|
const command = approveCommand(target);
|
|
588
612
|
const text = [
|
|
589
613
|
...flagsToTell(economy, nowOf(ctx)),
|
|
590
|
-
`${change.scope.live ? 'Publishing this change to the live economy' : 'Going live'}: ${plural(p.transactions.length, 'transaction')}, ${plural(p.approvals, 'wallet approval')}, about ${c.setup.totalSol} SOL on devnet:`,
|
|
614
|
+
`${change.scope.live ? 'Publishing this change to the live economy' : 'Going live'}: ${renaming ? 'at most ' : ''}${plural(p.transactions.length, 'transaction')}, ${plural(p.approvals, 'wallet approval')}, about ${c.setup.totalSol} SOL on devnet:`,
|
|
591
615
|
...steps.map((s, i) => `${i + 1}. ${s}`),
|
|
592
616
|
'',
|
|
593
617
|
`To put it live, the person runs this in a terminal in the project folder (not you): ${command}`,
|
|
@@ -688,6 +712,145 @@ export const tools = [
|
|
|
688
712
|
return { ok: true, rows, text: text + footer };
|
|
689
713
|
},
|
|
690
714
|
},
|
|
715
|
+
{
|
|
716
|
+
name: 'xsolana_token',
|
|
717
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
718
|
+
description:
|
|
719
|
+
'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 devnet (or XSOLANA_RPC_URL): the mint and its name record only, never the link the record names.',
|
|
720
|
+
inputSchema: {
|
|
721
|
+
type: 'object',
|
|
722
|
+
properties: {
|
|
723
|
+
mint: { type: 'string', description: 'The token’s mint address.' },
|
|
724
|
+
key: {
|
|
725
|
+
type: 'string',
|
|
726
|
+
pattern: '^[a-z][a-z0-9-]{0,31}$',
|
|
727
|
+
description: 'What the spec will call it (default: its ticker, in the letters a key takes).',
|
|
728
|
+
},
|
|
729
|
+
project: {
|
|
730
|
+
type: 'string',
|
|
731
|
+
description:
|
|
732
|
+
'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.',
|
|
733
|
+
},
|
|
734
|
+
},
|
|
735
|
+
required: ['mint'],
|
|
736
|
+
additionalProperties: false,
|
|
737
|
+
},
|
|
738
|
+
async handler(input, ctx) {
|
|
739
|
+
const mint = String(input.mint ?? '').trim();
|
|
740
|
+
try {
|
|
741
|
+
addressBytes(mint);
|
|
742
|
+
} catch {
|
|
743
|
+
return {
|
|
744
|
+
ok: false,
|
|
745
|
+
text: `${JSON.stringify(mint)} is not a Solana address. Give the token’s mint address.${footer}`,
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
// Devnet only: a mainnet URL is refused, and so is a chain whose first block is mainnet's or testnet's.
|
|
749
|
+
const rpc = (ctx?.rpc ?? rpcClient)(notMainnet(process.env.XSOLANA_RPC_URL || DEVNET_RPC));
|
|
750
|
+
if (!ctx?.rpc) await checkCluster(rpc);
|
|
751
|
+
let project = null;
|
|
752
|
+
if (input.project !== undefined) {
|
|
753
|
+
project = String(input.project).trim();
|
|
754
|
+
try {
|
|
755
|
+
addressBytes(project);
|
|
756
|
+
} catch {
|
|
757
|
+
return {
|
|
758
|
+
ok: false,
|
|
759
|
+
text: `${JSON.stringify(project)} is not a Solana address. Give the project’s address, or leave it out.${footer}`,
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
const [account, record] = await rpc.accounts([mint, metadataAddress(mint)]);
|
|
764
|
+
// A transfer fee changes on an epoch: with the chain's current one, a fee since lowered reads as it is now.
|
|
765
|
+
const epoch =
|
|
766
|
+
account && typeof rpc.call === 'function'
|
|
767
|
+
? await rpc.call('getEpochInfo').then(
|
|
768
|
+
e => Number(e.epoch),
|
|
769
|
+
() => null,
|
|
770
|
+
)
|
|
771
|
+
: null;
|
|
772
|
+
const token = tokenEntry(mint, account, record?.data ?? null, {
|
|
773
|
+
...(input.key ? { key: input.key } : {}),
|
|
774
|
+
project,
|
|
775
|
+
epoch,
|
|
776
|
+
});
|
|
777
|
+
if (!token)
|
|
778
|
+
return {
|
|
779
|
+
ok: false,
|
|
780
|
+
text: `${
|
|
781
|
+
account
|
|
782
|
+
? `${mint} is not a token mint on ${CLUSTER} (a token account or a wallet is not the mint: an explorer’s token page names it)`
|
|
783
|
+
: `There is nothing at ${mint} on ${CLUSTER}. A coin launched on mainnet is not on ${CLUSTER}, where loot runs for now`
|
|
784
|
+
}.${footer}`,
|
|
785
|
+
};
|
|
786
|
+
if (token.source === 'sol')
|
|
787
|
+
return {
|
|
788
|
+
ok: true,
|
|
789
|
+
token,
|
|
790
|
+
text: `${mint} is wrapped SOL: in a spec that is SOL itself.\n\nIn the spec’s "tokens":\n${JSON.stringify(token)}${footer}`,
|
|
791
|
+
};
|
|
792
|
+
const read = parseMint(mint, account.owner, account.data, record?.data ?? null);
|
|
793
|
+
const supply = Number(BigInt(read.supply)) / 10 ** read.decimals;
|
|
794
|
+
const p = token.powers;
|
|
795
|
+
const state = mintState(account);
|
|
796
|
+
// The name and ticker are the token's own writing, anyone's to set: given as the entry has them (one line, cut
|
|
797
|
+
// to a spec's lengths), in quotes, as labels and never as words of this tool.
|
|
798
|
+
const called =
|
|
799
|
+
token.symbol || token.name
|
|
800
|
+
? `calls itself ${[token.name && `“${token.name}”`, token.symbol && `ticker “${token.symbol}”`].filter(Boolean).join(', ')} (its own record’s words: a label anyone can write, not a fact)`
|
|
801
|
+
: 'has no name record, so wallets show it as an unknown token';
|
|
802
|
+
// What each power lets whoever holds it do, in the checker's words (check.mjs W-MINT-POWERS).
|
|
803
|
+
const can = [
|
|
804
|
+
p.mintAuthority === 'someone else' && `mint more of it whenever they want (${read.mintAuthority} can)`,
|
|
805
|
+
p.mintAuthority === 'project' && null,
|
|
806
|
+
p.freeze && 'freeze any account holding it, an economy’s pools and vaults included',
|
|
807
|
+
p.permanentDelegate && 'move or burn it out of any account',
|
|
808
|
+
p.transferHook && 'run a program of their own on every transfer, which can refuse one',
|
|
809
|
+
p.transferFeePercent > 0 && `keep ${p.transferFeePercent}% of every transfer`,
|
|
810
|
+
p.feeChangeable && 'raise its transfer fee, up to all of a transfer',
|
|
811
|
+
p.closeAuthority && 'close the mint and make it again with other powers',
|
|
812
|
+
p.pausable && 'pause every transfer of it',
|
|
813
|
+
p.defaultFrozen && 'have every new account of it start frozen',
|
|
814
|
+
!p.defaultFrozen && p.defaultState && p.freeze && 'switch every new account of it to start frozen',
|
|
815
|
+
].filter(Boolean);
|
|
816
|
+
const also = [
|
|
817
|
+
p.nonTransferable && 'It cannot be transferred at all: nothing can be paid, staked or given as a prize in it.',
|
|
818
|
+
p.confidentialTransfers &&
|
|
819
|
+
'Its holders can turn plain transfers into their account away (confidential transfers).',
|
|
820
|
+
state.paused && 'It is paused now: nothing of it moves until its issuer ends the pause.',
|
|
821
|
+
state.scaled &&
|
|
822
|
+
`Wallets show its amounts multiplied by a rate its mint carries${state.scaler ? ', which its issuer can change' : ''}: an economy counts the amounts under it, so a price in a spec is not the number a wallet shows.`,
|
|
823
|
+
p.mintAuthority === 'project' &&
|
|
824
|
+
'Its mint authority is the project given: the project mints it, as its rules say.',
|
|
825
|
+
project &&
|
|
826
|
+
p.mintAuthority === 'someone else' &&
|
|
827
|
+
`Its mint authority is not the project given (${project}): until it is handed over, nothing the economy mints in it lands.`,
|
|
828
|
+
].filter(Boolean);
|
|
829
|
+
const text = [
|
|
830
|
+
`The token at ${mint} on ${CLUSTER}: ${read.program === 'token-2022' ? 'a Token-2022' : 'a classic SPL'} token, ${plural(read.decimals, 'decimal')}, ${supply.toLocaleString('en-US')} in existence${p.mintAuthority === 'none' ? ', and nobody can mint more' : ''}. It ${called}.`,
|
|
831
|
+
can.length
|
|
832
|
+
? `Whoever controls its mint can:\n${can.map(c => `- ${c}`).join('\n')}\nAn economy in it is only as safe as the token: say so where players pay, stake or are paid.`
|
|
833
|
+
: `Its mint has no key that can freeze it, take it, charge on it or stop a transfer${p.mintAuthority === 'project' ? ' (the project mints it)' : ''}.`,
|
|
834
|
+
...also,
|
|
835
|
+
`In the spec’s "tokens" (xsolana_check then says what each power means for the economy’s parts):\n${JSON.stringify(token, null, 2)}`,
|
|
836
|
+
].join('\n\n');
|
|
837
|
+
return {
|
|
838
|
+
ok: true,
|
|
839
|
+
token,
|
|
840
|
+
mint: {
|
|
841
|
+
address: mint,
|
|
842
|
+
program: read.program,
|
|
843
|
+
decimals: read.decimals,
|
|
844
|
+
supply: read.supply,
|
|
845
|
+
name: token.name ?? null,
|
|
846
|
+
symbol: token.symbol ?? null,
|
|
847
|
+
mintAuthority: read.mintAuthority,
|
|
848
|
+
freezeAuthority: read.freezeAuthority,
|
|
849
|
+
},
|
|
850
|
+
text: text + footer,
|
|
851
|
+
};
|
|
852
|
+
},
|
|
853
|
+
},
|
|
691
854
|
{
|
|
692
855
|
name: 'xsolana_client',
|
|
693
856
|
annotations: READ,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xgamesfun/solana",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.4",
|
|
4
4
|
"mcpName": "io.github.XGamesFun/solana-kit",
|
|
5
5
|
"description": "Loot boxes, gacha, shops, lotteries, auctions, NFT staking, crafting and rewards on Solana without writing a smart contract: one shared program, its JS client, a CLI, and an MCP server and skill so Claude Code, Codex or any AI agent can design, check, simulate and launch an economy.",
|
|
6
6
|
"license": "Apache-2.0",
|
package/release.json
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
"sbfBytes": 1783800,
|
|
5
5
|
"sbfSha256": "af318ccfa4d2901076b85fcd1b4467b03253adf0de16e73a9dfc1ef8077b2c14",
|
|
6
6
|
"idlSha256": "0e88fc826a585cf17917cbc654e33b68232771769fe9aae1d5899a257940ff47",
|
|
7
|
-
"clientSha256": "
|
|
7
|
+
"clientSha256": "fcb5710a80efbff36c80d0249104c8d7c65b9d84cf70c12b8567e3a7d0af4a2b"
|
|
8
8
|
}
|
|
@@ -9,8 +9,9 @@ An economy is one JSON spec (`xsolana.json` in the project) on **loot**, a Solan
|
|
|
9
9
|
writes or deploys a contract: the spec is checked, simulated and priced by the `xsolana_*` tools, and the project's
|
|
10
10
|
owner puts it live by approving in their own wallet. It runs on **devnet** until the program is audited.
|
|
11
11
|
|
|
12
|
-
The tools are the `xsolana_*` MCP tools. Without MCP, the same from a terminal: `npx -y @xgamesfun/solana@0.26.
|
|
13
|
-
|
|
12
|
+
The tools are the `xsolana_*` MCP tools. Without MCP, the same from a terminal: `npx -y @xgamesfun/solana@0.26.4 <guide|examples|check|simulate|cost|explain|review|publish|status> [xsolana.json]`,
|
|
13
|
+
`npx -y @xgamesfun/solana@0.26.4 token <mint>` for a coin made elsewhere,
|
|
14
|
+
or `npx -y @xgamesfun/solana@0.26.4 tool <name> '<json>'` for any tool (always with the exact version).
|
|
14
15
|
|
|
15
16
|
## Rules (always)
|
|
16
17
|
|
|
@@ -26,8 +27,9 @@ or `npx -y @xgamesfun/solana@0.26.2 tool <name> '<json>'` for any tool (always w
|
|
|
26
27
|
`xsolana_simulate`, `xsolana_cost` and `xsolana_explain`, never your own arithmetic. What a player pays is the tools'
|
|
27
28
|
"in all" number for that action (price, fee, oracle, network and rent that never comes back): quote it as is.
|
|
28
29
|
6. **Flag the law once.** The first time the checker raises `W-CHANCE-PRIZE` (paid chance at money: boxes with
|
|
29
|
-
prizes, lotteries, contests), `W-CHANCE-ITEMS` (paid random collectibles a player can resell: loot boxes, gacha)
|
|
30
|
-
`W-REVENUE-SHARE` (stakers paid from sales)
|
|
30
|
+
prizes, lotteries, contests), `W-CHANCE-ITEMS` (paid random collectibles a player can resell: loot boxes, gacha),
|
|
31
|
+
`W-REVENUE-SHARE` (stakers paid from sales) or `W-TOKEN-SALE` (a presale: people pay for a share of a new token),
|
|
32
|
+
say it in one plain sentence. Don't repeat it in later answers, or add
|
|
31
33
|
legal notes to pages and apps you build, unless the person asks or a flag of a new kind appears. When they ask about
|
|
32
34
|
the law, answer what you know and leave the rest to their lawyer: you are not one. Never call anything an
|
|
33
35
|
investment, a return or passive income, and never promise it is safe. The approval page shows the flags and that
|
|
@@ -121,13 +123,33 @@ or `npx -y @xgamesfun/solana@0.26.2 tool <name> '<json>'` for any tool (always w
|
|
|
121
123
|
level would cost. Run it again after every change that touches a route that pays.
|
|
122
124
|
9. **When they say "put it live"**: `xsolana_publish` lists every step and its cost and gives the command. Tell them to
|
|
123
125
|
run it themselves in the project folder, exactly as `xsolana_publish` gives it (it names the exact version:
|
|
124
|
-
`npx -y @xgamesfun/solana@0.26.
|
|
126
|
+
`npx -y @xgamesfun/solana@0.26.4 approve xsolana.json`; never drop the version). It opens a page on their computer where
|
|
125
127
|
they connect a devnet wallet and approve; what lands is written back into `xsolana.json`. You publish nothing.
|
|
126
128
|
10. **After it is live**: `xsolana_status` shows each part on chain; read it before acting on what the person says
|
|
127
129
|
happened. A later change is the same loop: save, publish, and the approval sends only what changed. What only the
|
|
128
130
|
owner signs (open or decide a contest, pay out) goes on an owner page they approve in their own wallet:
|
|
129
131
|
`references/after-launch.md`.
|
|
130
132
|
|
|
133
|
+
## When they ask for a token
|
|
134
|
+
|
|
135
|
+
"A token for my game" is one of four things. Find out which from what they say it is for, before writing anything
|
|
136
|
+
(ask only when they haven't said):
|
|
137
|
+
|
|
138
|
+
| They mean | It is | In the spec |
|
|
139
|
+
| --------------------------------------------------------------------------- | ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
140
|
+
| points, tickets, shards: what players earn and spend in the game | a token the project mints as its rules say | `source: "project"`, given by a recipe's or a grant's prize (`"from": "mint"`), a farm's `rate` (`"minted": true`) or a schedule (`"does": "issue"`) |
|
|
141
|
+
| "our own coin, 10 million, we hand it out", a community token | a fixed supply, all of it to the owner, no more ever | `source: "project"` with `supply`; pools are seeded from it, and a presale (a contest), sealed vesting (a schedule) and a farm hand it out |
|
|
142
|
+
| "a coin people can trade", "on pump.fun", "a bonding curve", "creator fees" | a market, which loot does not run | they launch it on a launchpad or an AMM, in their own wallet; then `xsolana_token {"mint": …}` gives its entry, and loot's shops, boxes, farms and gates use it |
|
|
143
|
+
| "our token", "the coin we launched", "this mint" | a coin that exists | `xsolana_token {"mint": …}`: its entry with decimals, program and `powers` read from the chain. Never type them by hand, and never guess an address |
|
|
144
|
+
|
|
145
|
+
Say what each gives up. The first two have no public market: nobody trades them unless the project lists them
|
|
146
|
+
somewhere itself. A coin launched on a market usually has nobody left who can mint it (`xsolana_token` says so): the
|
|
147
|
+
economy pays out only what its owner puts into its pools. On devnet a coin trades nothing of value.
|
|
148
|
+
|
|
149
|
+
A token the setup makes is named on chain as it goes live, so ask for its name, its ticker and a picture first
|
|
150
|
+
(`references/telling-the-person.md`). Whatever the kind, rule 6 holds: never call a token an investment or promise it
|
|
151
|
+
a price.
|
|
152
|
+
|
|
131
153
|
## Building the app around it
|
|
132
154
|
|
|
133
155
|
A game, a site or a bot calls the live economy with the player's own wallet, through the package's player module
|
|
@@ -119,7 +119,7 @@ maps to a part of the spec (`xsolana_guide` has every field).
|
|
|
119
119
|
| "holders of the ticket claim a free badge once" | an open grant: no `vouchers`, `keys` or `list`, a `gate` of the ticket, and `limits.perWallet: 1` (each ticket shown claims once too) |
|
|
120
120
|
| "bring your own NFT", "any NFT of a partner collection can play", "holders of X get" | a `gate` (or a farm's, or odds') rule with `collection`: the collection's address; the project's notes about each NFT (a level) go in its Sheet |
|
|
121
121
|
| "our own token, 10 million, we keep it", "a fixed supply", "a community token" | `source: "project"` with `supply`: going live mints all of it to the owner and turns minting off for good; pools are seeded from it |
|
|
122
|
-
| "our token", "the coin we already launched", "this mint" | `source: "existing"
|
|
122
|
+
| "our token", "the coin we already launched", "this mint" | `source: "existing"`: ask for the mint's address, and `xsolana_token {"mint": …}` gives the whole entry (decimals, program, `powers`). loot doesn't put a token on a market: for trading, launch it on a token launchpad or an exchange first (SKILL.md, "When they ask for a token") |
|
|
123
123
|
| "Token-2022", "a transfer fee" | `program: "token-2022"` and `powers.transferFeePercent` |
|
|
124
124
|
| "tokens only, no NFTs" | `"collection": false`: no collection is made (no collectibles; normal items and tokens work) |
|
|
125
125
|
| "mint into our existing collection", "two collections" | `collections`: Core collections the owner's wallet already controls, each with the project added as an update delegate; an item's `collection` names the one it is minted into |
|
|
@@ -26,7 +26,9 @@ and the spec differ (a limit, an amount, a key not set yet), change one of them
|
|
|
26
26
|
6. **Flags for the law, once.** `W-CHANCE-PRIZE`: "Players pay for a chance at money. That is gambling in many places once
|
|
27
27
|
it is real money; this runs on devnet only." `W-CHANCE-ITEMS`: "Players pay for random items they can resell: some
|
|
28
28
|
places treat that as gambling, and many require the odds to be shown." `W-REVENUE-SHARE`: "Stakers are paid from
|
|
29
|
-
what players spend; regulators look at that when they decide whether a token is a security."
|
|
29
|
+
what players spend; regulators look at that when they decide whether a token is a security." `W-TOKEN-SALE`:
|
|
30
|
+
"People pay for a share of a new token; selling a token to raise money is what securities law looks at first."
|
|
31
|
+
Say each once, the
|
|
30
32
|
first time the checker raises it; then leave them, saying them again only when the person asks or a flag of a new
|
|
31
33
|
kind appears, and keep them out of pages and apps unless asked. The approval page shows them, with the program's
|
|
32
34
|
status (not independently audited, as is, at their own risk, theirs to make legal where they offer it), and keeps
|
|
@@ -120,8 +122,10 @@ Don'ts:
|
|
|
120
122
|
- **A token the setup makes is named on chain as it goes live**: its `name`, its `symbol` and its `uri` (a link to a
|
|
121
123
|
JSON file the project hosts, `{ "name", "symbol", "image": "https://…" }`), which is what wallets and explorers show.
|
|
122
124
|
Ask for the name, the ticker and a picture before going live: with no `uri` it shows by name and ticker with no
|
|
123
|
-
picture. Only the owner's wallet can change the three later (Token Metadata's rule, not loot's)
|
|
124
|
-
|
|
125
|
+
picture. Only the owner's wallet can change the three later (Token Metadata's rule, not loot's): change them in the
|
|
126
|
+
spec and approve again, and the record is written again for the price of a transaction (approving reads the record
|
|
127
|
+
first: one its owner handed to another wallet, made unchangeable or gave a royalty or creators outside these tools
|
|
128
|
+
is left as it is, and the page says so at each approve until the spec gives the old name back). The record costs about 0.014 SOL (`xsolana_cost` says it:
|
|
125
129
|
rent, and 0.01 SOL Token Metadata keeps). A token that went live before the tools wrote one has none and
|
|
126
130
|
can't be given one: only a mint's own authority can name it, and its minting was handed on or turned off.
|
|
127
131
|
- **NFTs the project has no authority over** (any collection but its own): they count as they are. Say that
|
|
@@ -36,5 +36,50 @@ export declare function createFungibleMetadataIx({ mint, authority, payer, name,
|
|
|
36
36
|
}[];
|
|
37
37
|
data: Uint8Array<any>;
|
|
38
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Token Metadata's UpdateMetadataAccountV2 for a fungible token's record: a new name, ticker and link ('' for none),
|
|
41
|
+
* all three written as given. `authority` is the record's update authority (for a token a setup made: the project's
|
|
42
|
+
* owner) and signs; it stays the update authority, and the record stays changeable. The record's words are written
|
|
43
|
+
* whole, with no royalty, creators, collection or uses: as a record a setup made has them. One that was given any of
|
|
44
|
+
* those outside these tools would lose them (or refuse the write), so the approval sends this only to a record that
|
|
45
|
+
* has none (`parseRecord`'s `plain`; approve/live-check.mjs readRenames). The mint is untouched, and it costs only the
|
|
46
|
+
* transaction: the record keeps its size.
|
|
47
|
+
*/
|
|
48
|
+
export declare function updateFungibleMetadataIx({ mint, authority, name, symbol, uri }: {
|
|
49
|
+
authority: any;
|
|
50
|
+
mint: any;
|
|
51
|
+
name: any;
|
|
52
|
+
symbol: any;
|
|
53
|
+
uri?: string | undefined;
|
|
54
|
+
}): {
|
|
55
|
+
programId: string;
|
|
56
|
+
keys: {
|
|
57
|
+
pubkey: any;
|
|
58
|
+
isSigner: any;
|
|
59
|
+
isWritable: any;
|
|
60
|
+
}[];
|
|
61
|
+
data: Uint8Array<any>;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* A Token Metadata record as the chain holds it, or null when the data is not one (its first byte says a metadata
|
|
65
|
+
* record; the strings are padded with NULs to their full length):
|
|
66
|
+
* { updateAuthority, mint, name, symbol, uri, royalty, creators, mutable, collection, uses, plain }.
|
|
67
|
+
* `royalty`: its resale royalty, in hundredths of a percent. `creators`: how many it lists. `mutable`: its update
|
|
68
|
+
* authority can still change it. `collection`, `uses`: whether it names one. `plain`: none of royalty, creators,
|
|
69
|
+
* collection or uses, as a setup's own record is: writing its words again changes nothing else of it.
|
|
70
|
+
*/
|
|
71
|
+
export declare function parseRecord(data: any): {
|
|
72
|
+
updateAuthority: string;
|
|
73
|
+
mint: string;
|
|
74
|
+
name: string;
|
|
75
|
+
symbol: string;
|
|
76
|
+
uri: string;
|
|
77
|
+
royalty: number;
|
|
78
|
+
creators: number;
|
|
79
|
+
mutable: boolean;
|
|
80
|
+
collection: boolean;
|
|
81
|
+
uses: boolean;
|
|
82
|
+
plain: boolean;
|
|
83
|
+
} | null;
|
|
39
84
|
/** The update authority a Token Metadata record names (who can change its name, ticker and link). */
|
|
40
85
|
export declare const metadataUpdateAuthority: (data: any) => string | null;
|
package/types/chain/mint.d.ts
CHANGED
|
@@ -23,3 +23,32 @@ export declare function parseMint(address: any, owner: any, data: any, metadataD
|
|
|
23
23
|
symbol: string | null;
|
|
24
24
|
uri: string | null;
|
|
25
25
|
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* A token made elsewhere as an economy spec names it: its `tokens` entry (`source: "existing"`), every field read from
|
|
28
|
+
* the chain so nothing is typed in by hand: the mint, its decimals and token program, its name and ticker when it has
|
|
29
|
+
* a name record, and `powers` (token2022.js `powersOf`: what the mint's own keys can do). `account`: the mint's
|
|
30
|
+
* ({ owner, data }); `record`: its Token Metadata record's data, when there is one. `key`: what the spec will call it
|
|
31
|
+
* (default: its ticker in the letters a key takes, else "token"). `project`: the loot project, whose own tokens read
|
|
32
|
+
* `mintAuthority: "project"`; `epoch`: the chain's current epoch, for a transfer fee since changed (`powersOf`). The
|
|
33
|
+
* name and ticker are cut to what a spec takes, on one line. Wrapped SOL is SOL (`{ key: "sol", source: "sol" }`).
|
|
34
|
+
* Null when `account` is no mint.
|
|
35
|
+
*/
|
|
36
|
+
export declare function tokenEntry(address: any, account: any, record?: null, { key, project, epoch }?: {
|
|
37
|
+
epoch?: null | undefined;
|
|
38
|
+
key?: null | undefined;
|
|
39
|
+
project?: null | undefined;
|
|
40
|
+
}): {
|
|
41
|
+
key: string;
|
|
42
|
+
source: string;
|
|
43
|
+
} | {
|
|
44
|
+
key: string;
|
|
45
|
+
source: string;
|
|
46
|
+
name?: string | undefined;
|
|
47
|
+
symbol?: string | undefined;
|
|
48
|
+
decimals: any;
|
|
49
|
+
program: string;
|
|
50
|
+
mint: any;
|
|
51
|
+
powers: {
|
|
52
|
+
mintAuthority: string;
|
|
53
|
+
} | null;
|
|
54
|
+
} | null;
|
|
@@ -26,6 +26,44 @@ export declare function mintPowers({ owner, data }: {
|
|
|
26
26
|
data: any;
|
|
27
27
|
owner: any;
|
|
28
28
|
}): any[];
|
|
29
|
+
/**
|
|
30
|
+
* What a mint's own keys can do, as an economy spec's `powers` says it (schema `token.powers`), read from the mint's
|
|
31
|
+
* account (`owner`, its token program; `data`), so nobody has to look it up and type it in. Only what is so is named:
|
|
32
|
+
* a plain mint nobody can mint more of reads `{ mintAuthority: 'none' }`. `project`: the loot project's address, when
|
|
33
|
+
* known, whose own tokens read `mintAuthority: 'project'`; any other minter is `'someone else'`.
|
|
34
|
+
* freeze: a freeze authority; permanentDelegate; transferHook (a hook program, or an authority who can name one);
|
|
35
|
+
* transferFeePercent and feeChangeable (its authority is still there); closeAuthority; pausable; defaultState (the
|
|
36
|
+
* mint sets what new accounts start as) and defaultFrozen (they start frozen); nonTransferable;
|
|
37
|
+
* confidentialTransfers.
|
|
38
|
+
* A mint holds two transfer fees: the one in force until an epoch, and the one from that epoch on. With `epoch` (the
|
|
39
|
+
* chain's current one) the fee read is the one that applies: the newer once its epoch has come, else the higher of
|
|
40
|
+
* the two (the fee today, or the one already set to follow). Without it, the higher of the two: never less than what
|
|
41
|
+
* a transfer pays, and a fee since lowered still reads at its old rate.
|
|
42
|
+
* Returns null when the account is not a mint of either token program.
|
|
43
|
+
*/
|
|
44
|
+
export declare function powersOf({ owner, data }: {
|
|
45
|
+
data: any;
|
|
46
|
+
owner: any;
|
|
47
|
+
}, { project, epoch }?: {
|
|
48
|
+
epoch?: null | undefined;
|
|
49
|
+
project?: null | undefined;
|
|
50
|
+
}): {
|
|
51
|
+
mintAuthority: string;
|
|
52
|
+
} | null;
|
|
53
|
+
/**
|
|
54
|
+
* What a Token-2022 mint's state does today that its powers don't say: `paused` (a pause is on: nothing moves),
|
|
55
|
+
* `scaled` (ScaledUiAmount or InterestBearing: wallets show amounts multiplied by a rate, not the base units the
|
|
56
|
+
* program moves and an economy counts in) and `scaler` (somebody can still change that rate). All false for a classic
|
|
57
|
+
* mint, or one with none of them.
|
|
58
|
+
*/
|
|
59
|
+
export declare function mintState({ owner, data }: {
|
|
60
|
+
data: any;
|
|
61
|
+
owner: any;
|
|
62
|
+
}): {
|
|
63
|
+
paused: boolean;
|
|
64
|
+
scaled: boolean;
|
|
65
|
+
scaler: boolean;
|
|
66
|
+
};
|
|
29
67
|
/** Whether a token account requires a memo on every transfer into it. */
|
|
30
68
|
export declare function requiresMemo(accountData: any): boolean;
|
|
31
69
|
/** The hook's list of extra accounts for this mint. */
|
package/types/economy/cost.d.mts
CHANGED
|
@@ -19,10 +19,11 @@ export declare function setupCost(plan: any, economy: any): {
|
|
|
19
19
|
export declare function actionCosts(economy: any, { now }?: Readonly<Record<string, any>>): any[];
|
|
20
20
|
/** Setup and play costs for a spec, or its refusals. */
|
|
21
21
|
/** `only` and `live`: a change to a live economy, priced as only what it publishes (live.mjs `changedParts`). */
|
|
22
|
-
export declare function cost(economy: any, { now, only, live }?: {
|
|
22
|
+
export declare function cost(economy: any, { now, only, live, renames }?: {
|
|
23
23
|
live?: null | undefined;
|
|
24
24
|
now?: number | undefined;
|
|
25
25
|
only?: null | undefined;
|
|
26
|
+
renames?: null | undefined;
|
|
26
27
|
}): {
|
|
27
28
|
ok: boolean;
|
|
28
29
|
refusals: any[];
|
|
@@ -35,7 +36,14 @@ export declare function cost(economy: any, { now, only, live }?: {
|
|
|
35
36
|
refusals?: undefined;
|
|
36
37
|
ok: boolean;
|
|
37
38
|
warnings: any[];
|
|
38
|
-
steps:
|
|
39
|
+
steps: {
|
|
40
|
+
creates: never[];
|
|
41
|
+
signers: string[];
|
|
42
|
+
id: string;
|
|
43
|
+
part: string;
|
|
44
|
+
says: string;
|
|
45
|
+
build: {};
|
|
46
|
+
}[];
|
|
39
47
|
transactions: {
|
|
40
48
|
signer: string;
|
|
41
49
|
steps: any[];
|
|
@@ -46,7 +54,7 @@ export declare function cost(economy: any, { now, only, live }?: {
|
|
|
46
54
|
alone: boolean;
|
|
47
55
|
}[];
|
|
48
56
|
approvals: number;
|
|
49
|
-
freshKeys:
|
|
57
|
+
freshKeys: string[];
|
|
50
58
|
} | {
|
|
51
59
|
ok: boolean;
|
|
52
60
|
setup: {
|
|
@@ -4,6 +4,7 @@ export declare const LEGAL: Readonly<{
|
|
|
4
4
|
'W-CHANCE-ITEMS': "Players pay for random items they can resell (a loot box). Some places treat that as gambling and many require the odds shown: show them on the page, and get a lawyer before real money.";
|
|
5
5
|
'W-AUCTION-SHILL': "Anyone, the seller included, can bid to push an auction’s price up (shill bidding): a reserve is the honest way to set a floor.";
|
|
6
6
|
'W-REVENUE-SHARE': "Stakers are paid from what players spend, which regulators look at when they decide whether a token is a security: before real money, get a lawyer, or pay rewards from emissions instead.";
|
|
7
|
+
'W-TOKEN-SALE': "People pay for a share of a new token (a presale). Selling a token to raise money is what securities law looks at first, and many places limit who may buy: before real money, get a lawyer.";
|
|
7
8
|
}>;
|
|
8
9
|
/** The legal flags a checker verdict raises, each once, in the order the checker raised them: [{ code, says }]. */
|
|
9
10
|
export declare const legalFlags: (verdict: any) => {
|