Skip to content

docs: serverless Audit Trail anchoring with Vercel waitUntil - #244

Draft
Edgadafi wants to merge 1 commit into
nirium-protocol:mainfrom
Edgadafi:cursor/docs-serverless-anchoring-waituntil-cf3d
Draft

Edgadafi wants to merge 1 commit into
nirium-protocol:mainfrom
Edgadafi:cursor/docs-serverless-anchoring-waituntil-cf3d

Conversation

@Edgadafi

@Edgadafi Edgadafi commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Documents how to anchor Nirium Audit Trail receipts from a serverless runtime (Vercel Functions) without losing the IPFS POST after the HTTP response returns, using waitUntil from @vercel/functions.

This came out of TIA's Audit Trail integration on mainnet (x402.holatia.app). TIA currently awaits the anchor inline with an 8 s timeout; this guide documents the waitUntil variant so builders can keep receipts durable on serverless without adding latency to the paid response.

What’s in the guide

  • Why a fire-and-forget promise can die after the response on serverless
  • Minimal hash / sign / respond / waitUntil example with Agent.anchorAuditRecord
  • Error handling and logging when anchoring fails (must not break the paid response)
  • Fallback when waitUntil is unavailable (local Node / other hosts)
  • Free verification afterward via GET /api/audit/info, IPFS gateway fetch, and nirium-cli verify
  • Env-var-only secrets; no real keys

Verification

Checked against:

  • packages/sdk/src/index.ts (AuditAnchorOptions, anchorAuditRecord → POST /api/audit/log)
  • Live GET /api/audit/info on testnet and mainnet boxes (IPFS CID, network set by the box, free beta rate-limited)

Files

  • docs/serverless-audit-waituntil.md
  • README.md (link)

AI assistance

Drafted with Claude Sonnet 5.5 via Cursor; API names and node behavior were checked against the SDK and live /api/audit/info before writing.

Add a guide for anchoring hash-only Audit Trail receipts from serverless
runtimes without losing the POST after the HTTP response returns.

Pattern generalized from a production x402 + Audit Trail integration on
Vercel: hash/sign synchronously, return the paid response, schedule
anchorAuditRecord with waitUntil, log failures without failing the
client, and verify afterward via IPFS / nirium-cli (free).

Verified against packages/sdk AuditAnchorOptions and live
GET /api/audit/info (IPFS CID, network set by the box, free beta
rate-limited).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Edgadafi <Edgadafi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants