Developers Forum for XinFin XDC Network

Salomon Morales
Salomon Morales

Posted on

Shipping a paid x402 API on XDC: NodeLens, a node-intelligence provider

I recently built and shipped a live provider on the XDC AI Marketplace. A REST API that offers XDC node and network intelligence per-call, settled in USDC via x402. This post covers what it does, how the pattern works at a high level, and the full endpoint list with working commands, in case it's useful to the next person building a provider on XDC.

Why

The XDC masternode staking contract locks 10M XDC for a 30-day unbonding period after resignation, calculated against network block production. Like any live network, real-world block timing has natural variation. I wanted a way to see that clearly and precisely in real time, rather than relying on the static assumption alone — so I built NodeLens to surface real, current unlock timing alongside network congestion and per-node performance data, all served as a paid API.

Stack

  • Node.js / Express — API server
  • XDC RPC — direct on-chain reads against the validator contract for candidate status and stake data
  • XDCScan API — mined-block history for performance scoring
  • x402 — HTTP payment protocol, settled via XDC AI's facilitator infrastructure
  • Claude (Anthropic) — powers a separate monitoring agent (more below)
  • Vercel — API hosting
  • Railway — monitoring agent hosting

How the payment flow works

The x402 pattern, at a high level:

  1. Agent requests the endpoint with no payment
  2. Server responds with a payment challenge — amount, asset, recipient, network
  3. Agent signs a gasless USDC authorization for the exact amount
  4. Agent resends the request with the signed payment attached
  5. Server verifies and settles the payment through XDC AI's facilitator, then returns the data along with the on-chain transaction hash as proof

No gas token required on the caller's side — settlement is sponsored. No invoicing, no manual reconciliation. The transaction hash is the receipt.

Here's a live example — a real, paid call to the network congestion endpoint on NodeLens, settled on XDC mainnet:

Transaction: 0x636ba2cdede35731f8f8b73f45f7da4d28779d6c3cfa7e0047f74b898718c5b3

$0.01 USDC, requested, paid, and settled autonomously — no manual steps, confirmed on-chain within seconds.

The monitoring agent

Alongside the API, I built a second service — NodeLens Watchdog — that runs on a schedule, pulls a full snapshot from the NodeLens API (network congestion, unlock timing, and status for a configured list of node addresses), and has Claude evaluate the snapshot against configurable alert thresholds. If something crosses a threshold, it fires a Telegram message and/or webhook with a structured summary and recommendation. It's a small demonstration of stacking an LLM-driven decision layer on top of a paid data API — directly reusable for anyone building an agent that needs to act on x402 data, not just fetch it. This part has not been made public yet as I am testing it but will release soon. Stay tuned!

Full endpoint list

Base URL: https://nodelens-api.vercel.app

Method Path Price Description
GET /v1/network/congestion $0.01 Rolling block-time averages (1h/24h/7d/30d) + congestion tier
GET /v1/network/unlock-risk $0.03 0–100 unlock predictability score + best/expected/worst unlock ETA
GET /v1/network/epoch $0.01 Current epoch, blocks to next boundary, reward schedule
GET /v1/node/:address/unlock-eta $0.05 Real unlock timing for a specific node if resigned now
GET /v1/node/:address/performance $0.05 Block production score/grade + block-production analysis
GET /v1/node/:address/status $0.02 Candidate status, stake amount, slashing flag
POST /v1/node/batch-status $0.25 Status for up to 20 node addresses in one call

Example responses from Claude XDCAI's integration

Claude's response to node status request

Claude's response to releasing unstated XDC tokens

Example calls via the XDC AI CLI:

# Network congestion
npx xdcai call https://nodelens-api.vercel.app/v1/network/congestion

# Unlock timing outlook
npx xdcai call https://nodelens-api.vercel.app/v1/network/unlock-risk

# Epoch info
npx xdcai call https://nodelens-api.vercel.app/v1/network/epoch

# Specific node unlock timing
npx xdcai call "https://nodelens-api.vercel.app/v1/node/0xYourNodeAddress/unlock-eta"

# Specific node performance
npx xdcai call "https://nodelens-api.vercel.app/v1/node/0xYourNodeAddress/performance"

# Specific node status
npx xdcai call "https://nodelens-api.vercel.app/v1/node/0xYourNodeAddress/status"

# Batch status for a node fleet
npx xdcai call https://nodelens-api.vercel.app/v1/node/batch-status \
  --method POST \
  --data '{"addresses": ["0xAddr1", "0xAddr2", "0xAddr3"]}'
Enter fullscreen mode Exit fullscreen mode

Every response includes the settlement txHash, verifiable on XDCScan. XDC Network's chain truth, not a dashboard claim. Go try it and let me know what other information regarding your node(s) you would like to see.

Discussion (0)