Standalone TypeScript API for risk checks, community reporting, and safety telemetry.
- Address risk checks (
/api/check/:address) - Recent report feed (
/api/reports) - Report submission payload prep (
POST /api/reports) - Agentic AI risk scoring with policy guardrails (
/api/ai) - Onchain anchor preparation + reads for AI and DePIN artifacts (
/api/anchors) - DePIN node registry + signed attestation ingestion (
/api/depin) - DePIN health projection endpoint (
GET /api/depin/health/:address) - Automatic fallback to demo mode when chain config is not set
npm install
cp .env.example .env
npm run devServer runs at http://localhost:4010 by default.
- Import this repo in Vercel.
- Keep root directory as
./. - Set runtime environment variables from
.env.example(at minimum:RPC_URL,CONTRACT_ADDRESS,AI_DECISION_ANCHOR_ADDRESS,DEPIN_ANCHOR_ADDRESS, and chain metadata). - Deploy. The backend uses
vercel.jsonto route all paths toapi/index.ts.
PORT: API portCORS_ORIGIN: allowed origin(s), comma-separatedCHAIN_NAME: label exposed in/healthCHAIN_ID: target EVM chain idCHAIN_CURRENCY_SYMBOL: native token symbolCHAIN_EXPLORER_URL: optional explorer base URLDEPLOYMENT_MANIFEST_PATH: optional local path to deployment manifest (latest.json)RPC_URL: EVM RPC endpoint (optional)CONTRACT_ADDRESS: deployed registry contract (optional)AI_DECISION_ANCHOR_ADDRESS: deployedX1SentinelAIDecisionAnchorcontract addressDEPIN_ANCHOR_ADDRESS: deployedX1SentinelDepinAnchorcontract addressDEPIN_EIP712_DOMAIN_NAME: EIP-712 domain name for DePIN signaturesDEPIN_EIP712_DOMAIN_VERSION: EIP-712 domain version for DePIN signaturesDEPIN_MAX_CLOCK_SKEW_SECONDS: max allowed future/past skew for signed payload timestampsDEPIN_MAX_ATTESTATION_AGE_SECONDS: max age for accepted attestation timestampsDEPIN_MAX_REGISTRATION_AGE_SECONDS: max age for accepted node registration timestampsDEPIN_NONCE_RETENTION_SECONDS: replay-protection nonce retention horizonDEPIN_ATTESTATION_RETENTION_SECONDS: in-memory attestation retention horizonDEPIN_HEALTH_WINDOW_HOURS: default lookback for/api/depin/health/:addressDEPIN_REQUIRE_NODE_REGISTRATION: require node registry membership before attestation ingestAI_SCORING_MODE:heuristic(local) oropenai(LLM-backed decisioning)AI_OPENAI_BASE_URL: OpenAI API base URL for scoring modeopenaiAI_OPENAI_MODEL: OpenAI model name used for decisioningOPENAI_API_KEY: OpenAI API key (required whenAI_SCORING_MODE=openai)AI_POLICY_WARN_THRESHOLD: score threshold for warning policyAI_POLICY_CHALLENGE_THRESHOLD: score threshold for challenge policyAI_POLICY_BLOCK_THRESHOLD: score threshold for block policyAI_POLICY_MIN_AUTOMATION_CONFIDENCE: minimum confidence to auto-execute elevated policy actionsAI_DECISION_RETENTION: per-address in-memory AI decision history size
If RPC_URL and CONTRACT_ADDRESS are missing, API serves demo-safe fallback data so UI prototyping is unblocked.
Default manifest path in .env.example points to ./contracts/deployments/latest.json.
Foundry contract package is located at contracts/.
cd contracts
forge install foundry-rs/forge-std --no-commit
cp .env.example .env
forge test -vvv- Network:
X1 EcoChain Testnet (Maculatus) - Chain ID:
10778 - RPC:
https://maculatus-rpc.x1eco.com/ - Explorer:
https://maculatus-scan.x1eco.com/ - Contract (
X1SentinelRegistry):0x5C4Be8d3fF603cba1A25dB2D269B4219c72F6855 - Contract (
X1SentinelAIDecisionAnchor):0x19CA137e578A81B9FBD0f7ca5D77468e238e4646 - Contract (
X1SentinelDepinAnchor):0x331Fdd4a93D9779030de8B086B4dfa21be11c6E2 - Registry deploy tx:
0x65c2bac2c2c5a01660147b90291fff5d72dd25eae29e87fe51a8fee47f7bf6be - AI anchor deploy tx:
0x0685da0d98c092482b67e450f4d4bfa1ad88e0e3974c58425ff32c96e3b1c853 - DePIN anchor deploy tx:
0x7c0dca95a35ec9700de98856437cad4cf7834f09773e4ea5808a1ffa6326d0a1
Backend env values should align with:
CHAIN_ID=10778
RPC_URL=https://maculatus-rpc.x1eco.com/
CONTRACT_ADDRESS=0x5C4Be8d3fF603cba1A25dB2D269B4219c72F6855
DEPLOYMENT_MANIFEST_PATH=./contracts/deployments/latest.json
AI_DECISION_ANCHOR_ADDRESS=0x19CA137e578A81B9FBD0f7ca5D77468e238e4646
DEPIN_ANCHOR_ADDRESS=0x331Fdd4a93D9779030de8B086B4dfa21be11c6E2GET /healthGET /api/configGET /api/check/:addressGET /api/reports?limit=10&offset=0GET /api/reports/:idPOST /api/reportsPOST /api/reports/:id/votePOST /api/reports/:id/resolveGET /api/ai/configPOST /api/ai/scoreGET /api/ai/decisions/:address?limit=10GET /api/anchors/configPOST /api/anchors/ai/preparePOST /api/anchors/depin/prepareGET /api/anchors/ai/:address?limit=10GET /api/anchors/depin/:address?limit=10GET /api/depin/eip712POST /api/depin/nodes/registerGET /api/depin/nodesGET /api/depin/nodes/:addressPATCH /api/depin/nodes/:address({ "active": true|false })POST /api/depin/attestGET /api/depin/health/:address?windowHours=24&latest=6
- Fetch signing schema with
GET /api/depin/eip712. - Register node with
POST /api/depin/nodes/register(signedNodeRegistrationpayload). - Submit telemetry with
POST /api/depin/attest(signedNodeAttestationpayload). - Query computed health using
GET /api/depin/health/:address.
- Aggregate context from onchain reports, privacy analysis, external flags, and DePIN health.
- Score with
/api/ai/score(heuristic by default, optional OpenAI model). - Apply deterministic policy guardrails (
allow,warn,challenge,manual_review,block). - Persist decision artifacts in memory (
inputHash,outputHash,modelVersion,generatedAt).
- Generate AI or DePIN artifacts in backend services (
/api/check,/api/ai/score,/api/depin/health). - Call
/api/anchors/*/prepareto receive wallet-ready contract method + params. - Submit transaction from authorized publisher wallet.
- Query anchored records using
/api/anchors/ai/:addressor/api/anchors/depin/:address.