Truvian Shield Docs

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)
ScriptWhat it does
npm run typecheckTypeScript, no emit
npm run test:preflightreplays stored answers through the desk rules
npm run test:resolvereplays recorded resolutions twice; decision and digest must not change
npm run test:minerlive checks against the miner's handlers, Solana included
npm run test:shield, npm run test:truth, npm run verify:truththe Season I check, the truth API, and the truth sources
npm run demo:guardthe guard() wallet wrapper in src/agent/guard.ts

Environment variables

VariableDefaultWhat it does
TELEGRAPH_API_KEYunsetthe Anjoman key the desks buy answers with, paid from its escrow; unset, nothing can be bought
TELEGRAPH_PAYER_KEYunseta wallet key for paying miners over x402 directly; also the default address visitors pay
SHIELD_MEMO_KEYunsetthe key memos are signed with; unset, memos are stored unsigned
SOLANA_DEVNET_KEYunsetbase64 secret key of the devnet wallet that sends settlements and anchors resolutions; unset, neither happens
TELEGRAPH_NODE_URLhttps://devnode.telegraphprotocol.comthe Telegraph node
TELEGRAPH_API_URLhttps://backend.telegraphprotocol.comthe Anjoman backend (escrow balance)
SHIELD_TRANSPORTAPI key, else x402, else directforce apikey, x402 or direct
SHIELD_API_ROUTE, SHIELD_X402_ROUTEengineagent or dispatcher to use the older routes
SHIELD_ESCROW_ACCOUNT0x2947…9055the escrow whose node ledger /api/stats reports
SHIELD_PREFLIGHT_BUDGET_USD0.1most a decision may spend on answers
SHIELD_API_KEY_MAX_SPEND_USD0.3most the node may reserve for one ask
SHIELD_API_KEY_CONCURRENCY3asks in flight at once (Anjoman allows three jobs per account)
SHIELD_MAX_PAYMENT_USDC0.1most Shield pays a miner per x402 call
SHIELD_REUSE_TTL_MS600000how long a bought fact is reused at $0
SHIELD_SETTLEMENT_MAX1most tokens one devnet settlement sends
SHIELD_PRICE_USD0.05what a visitor pays per run past the free allowance
SHIELD_PAYTOthe payer walletwhere visitors' payments go
SHIELD_PAYMENTSonoff to answer 429 instead of quoting a price
X402_CHAIN_ID, X402_CHAIN84532 (Base Sepolia)the chain visitors pay on
X402_USDC_ADDRESSCircle's USDC on that chainthe token visitors pay in
X402_FACILITATOR_URLhttps://facilitator.payai.networkverifies and settles visitors' payments
SHIELD_FREE_CHECKS_PER_IP, SHIELD_BURST_PER_MIN5, 3free runs per IP a day, and per minute
SHIELD_DAILY_CHECK_CAP, SHIELD_DAILY_SPEND_USD300, 5free runs and Telegraph spend a day, across everyone
SOLANA_DEVNET_RPC_URLhttps://api.devnet.solana.comthe RPC resolution anchors are sent through
SHIELD_MEMOS_FILE, SHIELD_RESOLVE_MEMOS_FILE, SHIELD_RECEIPTS_FILE, SHIELD_STATS_FILE.shield-*.json in the working directorywhere memos, resolutions, Season I reports and counters are kept
SHIELD_PORT / PORT, SHIELD_HOST / HOST8788, 127.0.0.1where Shield listens
SHIELD_PUBLIC_URLfrom the requestthe public origin written into payment requirements
SHIELD_TRUST_PROXYon0 when not behind a reverse proxy, so client IPs are not taken from headers
KeysKeys live only in the server's .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

PathWhat is there
src/shield/server.tsthe Shield server: routes, free allowance, x402, stats
src/shield/preflight.ts, holdings.ts, settlement.ts, resolve.tsthe desks' plans and rules
src/shield/telegraph.tsasking Telegraph: routed and pinned asks, rankings, escrow
src/shield/tokenFacts.ts, solana.ts, solanaHoldings.ts, solanaAnchor.tsShield's own chain reads, Solana sends and anchors
src/shield/memo.ts, x402server.ts, limits.ts, docs.tssigning, 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