Build
Self-hosting.
Clone the repository, put your keys in .env, and run npm run shield: the desks, the API and these docs come up on port 8788. Without a Telegraph key Shield still serves pages and memos, but cannot buy answers.
Run it
git clone https://github.com/mrnetwork0001/Truvian && cd Truvian
npm install
cp .env.example .env # then fill in the keys you have
npm run shield # Shield: desks, API, docs (port 8788)
npm run dev # the miner (port 8787)
npm run truth # the truth API (port 8790)
| Script | What it does |
|---|---|
npm run typecheck | TypeScript, no emit |
npm run test:preflight | replays stored answers through the desk rules |
npm run test:resolve | replays recorded resolutions twice; decision and digest must not change |
npm run test:miner | live checks against the miner's handlers, Solana included |
npm run test:shield, npm run test:truth, npm run verify:truth | the Season I check, the truth API, and the truth sources |
npm run demo:guard | the guard() wallet wrapper in src/agent/guard.ts |
Environment variables
| Variable | Default | What it does |
|---|---|---|
TELEGRAPH_API_KEY | unset | the Anjoman key the desks buy answers with, paid from its escrow; unset, nothing can be bought |
TELEGRAPH_PAYER_KEY | unset | a wallet key for paying miners over x402 directly; also the default address visitors pay |
SHIELD_MEMO_KEY | unset | the key memos are signed with; unset, memos are stored unsigned |
SOLANA_DEVNET_KEY | unset | base64 secret key of the devnet wallet that sends settlements and anchors resolutions; unset, neither happens |
TELEGRAPH_NODE_URL | https://devnode.telegraphprotocol.com | the Telegraph node |
TELEGRAPH_API_URL | https://backend.telegraphprotocol.com | the Anjoman backend (escrow balance) |
SHIELD_TRANSPORT | API key, else x402, else direct | force apikey, x402 or direct |
SHIELD_API_ROUTE, SHIELD_X402_ROUTE | engine | agent or dispatcher to use the older routes |
SHIELD_ESCROW_ACCOUNT | 0x2947…9055 | the escrow whose node ledger /api/stats reports |
SHIELD_PREFLIGHT_BUDGET_USD | 0.1 | most a decision may spend on answers |
SHIELD_API_KEY_MAX_SPEND_USD | 0.3 | most the node may reserve for one ask |
SHIELD_API_KEY_CONCURRENCY | 3 | asks in flight at once (Anjoman allows three jobs per account) |
SHIELD_MAX_PAYMENT_USDC | 0.1 | most Shield pays a miner per x402 call |
SHIELD_REUSE_TTL_MS | 600000 | how long a bought fact is reused at $0 |
SHIELD_SETTLEMENT_MAX | 1 | most tokens one devnet settlement sends |
SHIELD_PRICE_USD | 0.05 | what a visitor pays per run past the free allowance |
SHIELD_PAYTO | the payer wallet | where visitors' payments go |
SHIELD_PAYMENTS | on | off to answer 429 instead of quoting a price |
X402_CHAIN_ID, X402_CHAIN | 84532 (Base Sepolia) | the chain visitors pay on |
X402_USDC_ADDRESS | Circle's USDC on that chain | the token visitors pay in |
X402_FACILITATOR_URL | https://facilitator.payai.network | verifies and settles visitors' payments |
SHIELD_FREE_CHECKS_PER_IP, SHIELD_BURST_PER_MIN | 5, 3 | free runs per IP a day, and per minute |
SHIELD_DAILY_CHECK_CAP, SHIELD_DAILY_SPEND_USD | 300, 5 | free runs and Telegraph spend a day, across everyone |
SOLANA_DEVNET_RPC_URL | https://api.devnet.solana.com | the RPC resolution anchors are sent through |
SHIELD_MEMOS_FILE, SHIELD_RESOLVE_MEMOS_FILE, SHIELD_RECEIPTS_FILE, SHIELD_STATS_FILE | .shield-*.json in the working directory | where memos, resolutions, Season I reports and counters are kept |
SHIELD_PORT / PORT, SHIELD_HOST / HOST | 8788, 127.0.0.1 | where Shield listens |
SHIELD_PUBLIC_URL | from the request | the public origin written into payment requirements |
SHIELD_TRUST_PROXY | on | 0 when not behind a reverse proxy, so client IPs are not taken from headers |
.env, which git ignores. They are never sent to the browser, logged or written into a memo. Use a fresh wallet for SHIELD_MEMO_KEY and a devnet-only wallet for SOLANA_DEVNET_KEY.Deploying
truvian.xyz runs Shield under pm2 behind nginx: deploy/ecosystem.shield.config.cjs and deploy/nginx-shield.conf; the miner has deploy/ecosystem.config.cjs and deploy/nginx-miner.conf. A deploy is git pull --ff-only, npm install when dependencies change, and a restart of that one pm2 app. Things that will bite you: public RPC endpoints change within days (run npm run test:miner before trusting the chain list), the Telegraph registry contract moves without notice (check it before any transaction), and a client IP is only right when nginx forwards it and SHIELD_TRUST_PROXY is on.
Repository map
| Path | What is there |
|---|---|
src/shield/server.ts | the Shield server: routes, free allowance, x402, stats |
src/shield/preflight.ts, holdings.ts, settlement.ts, resolve.ts | the desks' plans and rules |
src/shield/telegraph.ts | asking Telegraph: routed and pinned asks, rankings, escrow |
src/shield/tokenFacts.ts, solana.ts, solanaHoldings.ts, solanaAnchor.ts | Shield's own chain reads, Solana sends and anchors |
src/shield/memo.ts, x402server.ts, limits.ts, docs.ts | signing, payments, rate limits, these docs |
src/shield/public/ | the site: landing, desks, resolve, docs, pay.js, wallet.js |
src/miner/ | the miner (registration 6194) |
src/truth/ | the truth API |
evaluator/ | the evaluator adapters and truth sources |
telegraph/ | the miner YAML, registration notes, PREFLIGHT.md and SETTLEMENT.md |
src/scripts/ | tests, fixtures and one-off probes |
