d402distributed 402
Implementation reference

Reference

Concrete endpoints, headers, JSON shapes, CLI entry points, and operational handles for the current implementation. Public protocol names are d402; legacy dnc aliases remain where compatibility requires them.

HTTP endpoints

MethodPathResponse
GET/healthGateway liveness and public policy.
GET/.well-known/d402-gateway.jsonDiscovery document for clients.
GET/.well-known/dnc-gateway.jsonLegacy compatibility discovery endpoint.
GET/capabilitiesIndexed capability registrations and gateway-accepted manifests.
GET/healthzSimple readiness probe for public indexes such as Zero.
GET/openapi.jsonOpenAPI 3.1 document with payment metadata.
POST/tasks402 challenge, 200 sync result, or 202 async status.
GET/tasks/{taskId}Task record.
GET/tasks/{taskId}/resultAccepted result or 202.
GET/tasks/{taskId}/receiptValidation and settlement receipt.

Headers

HeaderDirectionPurpose
PAYMENT-REQUIREDGateway -> clientBase64 JSON x402-style challenge.
PAYMENT-SIGNATUREClient -> gatewayBase64 JSON payment payload supplied by x402 wallet/client.
PAYMENT-RESPONSEGateway -> clientBase64 JSON settlement response.
Authorization: Payment ...Client -> gatewaySolana direct payment proof body.
x-d402-idempotent-replayGateway -> clientCurrent implementation marker for accepted same-task replay.
x-dnc-idempotent-replayGateway -> clientLegacy compatibility marker for accepted same-task replay.

Health response

GET /health
{
  "ok": true,
  "nodeId": "gateway:abc123",
  "policy": {
    "price": "$0.01",
    "capabilityId": "web.page_to_markdown@1",
    "mode": "single",
    "fanout": 1,
    "quorum": 1,
    "deadlineMs": 30000,
    "allowAsync": true,
    "paymentRouter": "channel",
    "creatorCommission": {
      "pricingMode": "included",
      "scope": "exact-manifest",
      "maxRateBps": 2000,
      "payoutRail": "solana",
      "requiresEscrowForDirectProviderPayTo": true
    }
  }
}

Task request

POST /tasks
{
  "sync": true,
  "input": {
    "url": "https://example.com",
    "timeoutMs": 10000
  },
  "payment": {
    "refundAddress": "BuyerRefundWalletWhenEscrowIsUsed"
  }
}

Settlement receipt shape

GET /tasks/{taskId}/receipt
{
  "taskId": "task:...",
  "validationReceipt": {
    "status": "accepted",
    "acceptedClaimCids": ["sha256:..."],
    "rejectedClaimCids": []
  },
  "settlement": {
    "payouts": [
      {
        "account": "WorkerWallet...",
        "workerId": "node:worker",
        "amount": 0.009,
        "grossAmount": 0.01,
        "reason": "accepted-result"
      },
      {
        "account": "CreatorWallet...",
        "amount": 0.001,
        "grossAmount": 0.01,
        "reason": "creator-commission",
        "rateBps": 1000,
        "rail": "solana",
        "manifestCid": "sha256:...",
        "registrationCid": "sha256:...",
        "publisher": "node:publisher",
        "namespace": "example"
      }
    ],
    "refunds": []
  }
}

CLI commands

CommandPurpose
d402 nodeStart a peer, worker, gateway, or bootstrap role.
d402 taskSubmit a task through the peer network.
d402 http-taskCall the HTTP gateway and inspect payment challenges.
d402 x402-taskUse a real buyer wallet to complete x402 payment and retry.
d402 solana-taskInspect or complete Solana direct payment.
d402 solana-finalizerReplay persisted Solana task escrow finalization.
d402 solana-channel-maintainerPublish roots, withdraw claims, and reclaim safe rent.
d402 capability templateCreate a new capability manifest skeleton.
d402 capability validateValidate capability manifest shape and CID.
d402 capability registerCreate a signed registration envelope, including optional creator commission terms.
d402 capability implementation createCreate a signed runner package/release manifest for workers to install or audit.
d402 capability implementation installVerify and install a runner implementation with local env substitution.
d402 ops-statusInspect gateway safety state.
d402 ops-monitorRun continuous safety monitoring and alert dedupe.
d402 devnetRun a local multi-process TCP devnet.

Common environment variables

NameUse
D402_BUYER_PRIVATE_KEYEVM buyer key for x402 test/client flows.
D402_PROVIDER_PAYOUT_WALLETEVM provider payout wallet.
D402_X402_NETWORKEVM CAIP-2 network, for example eip155:8453.
D402_ESCROW_FACTORY_ADDRESSBase escrow factory contract address.
D402_ESCROW_TX_PRIVATE_KEYGas signer for escrow settlement transactions.
D402_SOLANA_RPC_URLSolana RPC endpoint.
D402_SOLANA_USDC_MINTSolana USDC mint.
D402_SOLANA_ESCROW_PROGRAM_IDSolana escrow/channel program ID.
D402_MAX_CREATOR_COMMISSION_BPSGateway cap for signed creator commissions. Defaults to 2000.
D402_SAFETY_MAX_TASK_BUDGETGateway per-task budget cap.
D402_SAFETY_MAX_CHANNEL_BALANCE_ATOMIC_UNITSPer-channel balance cap.

Known public constants

  • Base USDC: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
  • Solana USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
  • Solana deployed program ID: GG8giaUFeegrwD2T2fuHdSvriMsXBi12fmQ4edtFas2e
  • Initial capability: web.page_to_markdown@1
  • Creator commission schema: d402.creator_commission@1
  • Default maximum creator commission: 2000 bps, or 20%
  • Preferred discovery path: /.well-known/d402-gateway.json