The docs still listed only the original 16 tools; mcp/tools.ts has grown
to 78 (RealFi/Flare bridge, risk analytics, marketplace, automations).
Found while independently verifying this week's launch-maxxing submissions,
which had propagated the stale "16 tools" claim into live external PRs.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner directive (2026-11-11): submit a single project to the NEAR
Hackathon instead of two separate entries from the same person. Vendors
Ration's NEAR audit-anchor work (github.com/caelum0x/ration, commit
cff0ed3 + follow-ups) into ration-anchor/ as a first-class component:
- contracts-near/audit_anchor (NEAR Rust contract, 5/5 cargo tests
green, target/ deleted)
- signer/ — a new, self-contained Go module (no dependency on Ration's
other services or go.work) with the hand-rolled NEAR transaction
signer + JSON-RPC client (cross-checked byte-for-byte against
near-api-js) and the hash-chained audit ledger it anchors; 15/15 Go
tests green (go test ./... -race)
- docs/ and media/ — Ration's original pitch deck, demo recordings, and
submission checklist
Re-verified live via raw NEAR Testnet JSON-RPC this pass:
ration-anchor-286ca315f1.testnet still deployed and queryable, the
deliberate replay-rejection transaction still fails with nearcore's own
"sequence must strictly advance" panic — no redeploy needed.
Provenance notes added throughout (package doc comments, lib.rs header,
README) crediting the origin repo. README.md and HACKATHON.md rewritten
to tell one story: Cred402's SpendGuard enforces the protocol-level
spending limit, the vendored Audit Anchor proves the tamper-evident
spend history, both independently verifiable on NEAR Testnet. No mainnet
claims anywhere (see prior overclaim fix 524f2dd). cred402's own build
(npm run typecheck) and existing tests are untouched.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Narration line 2 said Cred402 is "already live on two other chains, and
now native NEAR" — false. Live checks against
cred402-1.onrender.com/v1/x402/{algorand,qie}/status both return
configured:false. The deck was already corrected (4eb21fe); this patches
the video's narration to match.
New line 2: "Cred402 sells credit scores to AI agents over a pay per
call payment protocol, and now it's enforced natively on NEAR." Same
Aura-2 voice (aura-2-asteria-en — re-derived acoustically, since no
voice ID was recorded in the original build: synthesized the real line 1
text in all 5 cataloged voices and compared pitch/spectral-centroid
against the shipped audio; asteria matched an order of magnitude closer
than the next candidate). Same per-line Deepgram nova-3 QC round-trip.
Only the line 2 window (8.9s-17.766s) was touched — confirmed by frame
diff that this whole span is a single static held title card in the
shipped video, so the patch could re-render just that card + new
captions + new audio and splice it between the untouched first 8.9s and
untouched remainder (which includes line 3's unmoved 19.5s start).
Re-transcribed the full final audio with nova-3 to confirm lines 1 and
3-6 are unchanged.
Duration unchanged (70.6s), resolution/fps/codec unchanged (1920x1080,
30fps, h264/aac). Re-mastered loudness: -14.8 LUFS integrated / -1.8
dBTP true peak (both within spec).
Reproducible recipe: media/video-recipe/line2-fix/ (generate_line2_audio.py
-> render_line2_assets.mjs -> build_patch.sh).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A judging pass found the deck said Cred402 is "already live on Algorand
and QIE." Live checks show otherwise: curl against
cred402-1.onrender.com/v1/x402/{algorand,qie}/status both return
"configured": false right now (pay-to address not set, neither route is
production-live). Corrected slides 4 and 10 of PITCH-DECK.md to state
this honestly and re-exported PDF/PPTX via marp-cli; re-rendered and
visually checked both slides for overflow/contrast after the edit.
Documented the correction and the one known remaining gap (the video's
narration line 2 still carries the old claim, baked into mastered audio,
not re-recorded this pass) in README.md.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
13-slide Marp deck (PDF+PPTX) mapping the Agent Economy track brief and
NEAR's stated judging criteria to SpendGuard's real on-chain proof, plus a
70.6s narrated demo video built entirely from real captures: the existing
asciinema-recorded SpendGuard loop, a fresh terminal recording made today
re-verifying the live testnet contract + 450/450 tests, and code-rendered
(Playwright/HTML) title cards. Deepgram Aura-2 narration with per-line ASR
round-trip QC, burned-in word-timed captions, loudness mastered to -14.6
LUFS / -1.9 dBTP true peak. No AI-generated footage; no paid APIs beyond
the existing Deepgram key.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Judge audit found the hackathon's literal eligibility rule ("each
README names the other") was only satisfied via HACKATHON.md, not
README.md itself. Add an explicit Ration cross-reference to the NEAR
Hackathon section of README.md. Also fix a stale "447 pass" comment
that disagreed with the real, live npm test result (450/450).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
HACKATHON.md described the live-Testnet SpendGuard demo and how to run it
yourself, but never linked the already-recorded proof artifact
(media/cred402-near-spend-guard-demo.mp4) — a judge who doesn't run the
commands had nothing to watch. Add the link.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds scripts/record_near_spend_guard_demo.mjs (npm run
record:near-spend-guard), which asciinema-records the real `npm run
demo:near-spend-guard` terminal session and renders it with agg/ffmpeg.
Ran it for real against the live spendguard-024e8dd6f7.testnet
contract: full build, 18/18 unit tests, sandbox integration test, then
25 real spend_to_seller calls, a real repay_credit_line, a real
top_up_allowance, one more real spend on the same key, a dispute
freeze, and a rejected post-freeze call.
Commits the real artifacts: media/cred402-near-spend-guard-demo.cast
(.gif, .mp4, poster.png). Updates SUBMISSION-CHECKLIST.md to mark the
video done and adds a ready-to-post X caption draft
(X-POST-DRAFT-2026-11-07.md) since no social-posting credentials exist
in this environment.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-07 hackathon security round (NEAR x402 / SpendGuard). Focus areas
checked this round: scam_detection.rs dispute/circuit-breaker path, near
finality handling in the x402 gateway, policy/exposure edge-math, and
same-signer concurrent spend_to_seller calls.
No new exploitable bug found. The one genuinely new test added here proves
(not just reasons about) focus area 4: fired two real spend_to_seller
transactions from the SAME Function Call Access Key via tokio::join! (true
concurrency, not sequential awaits) against a reservation sized so only one
could legally succeed. First attempt (with a cold near-workspaces nonce
cache) revealed a client-harness-only artifact: concurrent first-use nonce
fetching can produce two byte-identical transactions that nearcore
collapses into one execution — not a contract bug, confirmed by reading
near-workspaces' own fetch_tx_nonce. After warming the nonce cache so both
transactions get genuinely distinct nonces, the real result holds: one
spend succeeds, the other is correctly rejected by the contract's own
require! check ("requested spend exceeds the agent's remaining reserved
credit line") — no double-spend, no lost update, confirmed live against a
real local nearcore sandbox node.
scam_detection.rs (dispute spike + emergency freeze), near_finality.ts's
optimistic-settle-then-reconcile design, and policy.rs's clamp/overflow
behavior were all read end-to-end and ruled out — see cred402 plan history
for the full writeup of what was checked in each area.
18/18 Rust unit tests still green, cargo clippy clean, both sandbox tests
green, 450/450 TS tests green, tsc clean — zero regressions.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adversarial testing found a real, confirmed critical bug: the NEAR x402
self-verified facilitator only deduped payment proofs by sha256 of the
client-supplied PAYMENT-SIGNATURE header bytes, not by the real on-chain
transaction they decode to. Since a NEAR transfer is public ledger data,
anyone who observes ONE valid (signerId, transaction) pair for a payment
to the configured payTo account could re-encode it inside a byte-different
header (reordered JSON keys / an added ignored field) to mint a brand-new
paymentProofHash that the existing replay() barrier had never seen, and
ride that single real payment to an unlimited number of free paid
credit-score requests for unrelated agent_ids. Reproduced live against
the real store/gateway/finality code with a mocked RPC returning one
confirmed transaction: 3 distinct free settlements from 1 payment before
the fix, correctly reduced to 1 settlement + 2 rejections after it.
Fixes it with a second, independent, durably-atomic claim index keyed on
the transaction hash itself (NearPaymentAttemptStore.claimTransaction,
first-claim-wins via an exclusive `wx` file create, same primitive the
existing paymentProofHash claim uses), checked right after authorize()
and before the costly settle() RPC call. A legitimate retry of the SAME
resource with a re-encoded header still gets served the cached settled
response; a different resource request reusing someone else's already-
consumed transaction is rejected with 409.
Algorand/QIE x402 paths were checked for the same pattern and are not
affected: both settle through a real third-party x402 facilitator
(@x402/avm, @x402/evm) against a single-use signed-but-unbroadcast
payload, not a self-verified reference to an already-public transaction
— this exact replay primitive is unique to NEAR's hand-rolled facilitator
(no @x402/near package exists).
14/14 existing NEAR x402 tests still green, typecheck clean.
Fetched the live hackathon page (2026-11-05) and cross-checked the
owner-only checklist against the actual current form fields and X-post
requirements (tag @NEARProtocol + #NEARHackathon, demo video/screenshots
attached, 20-2000 char description, 13 tracks, team size up to 8+, NEAR
payout wallet). No new requirement surfaced vs. what was already
documented; tightened the exact wording so there is nothing left to
re-verify before the owner fills in identity/demo/form.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds the SpendGuard entrypoint flagged in HACKATHON.md as a known limit:
an agent with a still-ACTIVE spend key can now draw, repay, top up, and
draw again on the SAME key, not just at the ExposureBook ledger level.
- contracts-near/spend_guard/src/lib.rs: new admin-only top_up_allowance,
re-reserving freed headroom (capped by the agent's own policy-approved
credit line) and re-minting the agent's existing Function Call Access
Key via spend_key::retop_spend_key.
- src/spend_key.rs: retop_spend_key — a real NEAR protocol constraint
found and fixed live against a running nearcore sandbox: AddKey
unconditionally rejects an already-existing public key
(AddKeyAlreadyExists), so topping up means delete_key + re-add in the
SAME receipt, not a second AddKey call. Also fixed a clippy
doc_lazy_continuation nit in this file's module docs.
- src/exposure.rs: replaced two manual saturating-subtract patterns with
u128::saturating_sub (clippy implicit_saturating_sub), and added a unit
test proving repay-then-reserve-again reaches the full cap a second
time.
- tests/sandbox.rs: extended the real near-workspaces sandbox integration
test (genuinely running local nearcore node) to prove the full loop
live: draw -> repay -> top_up_allowance -> a real spend_to_seller call
that succeeds again on the SAME original key -> dispute spike -> freeze
-> revoked-key rejection.
- lib/x402/near_spend_guard_client.ts: repayCreditLine + topUpAllowance
client methods; scripts/near_spend_guard_full_demo.ts now exercises the
same real repay/top-up/draw-again loop against the LIVE deployed public
Testnet contract (spendguard-024e8dd6f7.testnet), not just the sandbox.
- scripts/near_spend_guard_redeploy.ts: new script to upgrade the
already-deployed contract's wasm in place (DeployContract replaces code
only, never storage) — used to push this change to the live Testnet
contract without losing its existing agent/exposure state.
Also fixes a real, judge-relevant finding hit while running the above:
NEAR's own legacy public RPC (rpc.testnet.near.org) now rejects most
calls with -429 "WARNING! THIS ENDPOINT IS DEPRECATED!". Every default
RPC URL in this repo (near_networks.ts, near_spend_guard_client.ts,
near_spend_guard_deploy.ts, docs/near_x402.md's example) now defaults to
FastNear's free public RPC instead; CRED402_NEAR_RPC_URL still overrides.
Updated the one test that asserted the old default.
18/18 Rust unit tests green, cargo clippy -D warnings clean, the sandbox
integration test passes against a real local nearcore node, the live
Testnet bonus loop passes against the real public contract, and the full
TS suite is 450/450 green with a clean typecheck.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Extends tests/sandbox.rs to call repay_credit_line against the live deployed
contract after a real spend, with before/after get_exposure assertions that
outstanding exposure actually zeroes out and reserved is untouched - closing
the gap commit 1cb3509 left open ("no repayment flow exists in this pass's
demo loop"). 17/17 unit tests still green, full sandbox test green against a
live local nearcore node.
Also documents a real architectural finding surfaced while building this: no
public entrypoint yet lets an agent with a still-active key draw against
freed headroom in the same authorization (key revocation and exposure freeze
are currently coupled). Updated HACKATHON.md/SUBMISSION-CHECKLIST.md to
describe SpendGuard for the AI Security & Defense track, previously undocumented.
Closes the two "ported but not wired" ExposureBook functions flagged in the
Day 7 writeup: freezing an agent (dispute-spike or emergency) now releases
its unspent reservation instead of leaving that capacity permanently locked
against max_allowed, and a new admin-only repay_credit_line entrypoint lets
a verified repayment reduce outstanding exposure — turning the approved
credit_line into an actual revolving line instead of a one-shot budget.
Verified: 17/17 unit tests (3 new), full near-workspaces sandbox integration
test green against a real local nearcore node.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Deployed SpendGuard to NEAR Testnet for real via near-api-js, driven
programmatically (cargo-near's create-dev-account/sign-with-keychain are
interactive-only, confirmed in the plan's own rehearsal):
contract account spendguard-024e8dd6f7.testnet, deploy + init transactions
both SuccessValue, independently re-verified via a raw RPC call to
rpc.testnet.near.org.
- scripts/near_spend_guard_deploy.ts: generates a keypair, creates the
account via the public testnet faucet, deploys the built wasm, calls
new({admin}).
- lib/x402/near_spend_guard_client.ts: typed near-api-js client
(SpendGuardClient) for request_spend_authorization / spend_to_seller /
report_dispute_spike / view methods. Does not touch near_gateway.ts /
near_rpc.ts / near_finality.ts.
- agents/near_spend_controlled_buyer_agent.ts: buyer_agent.ts-pattern agent
— gets authorized, spends repeatedly through its scoped key.
- agents/near_watchdog_agent.ts: watchdog_agent.ts-pattern agent — triggers
the dispute-spike circuit breaker.
- scripts/near_spend_guard_full_demo.ts (npm run demo:near-spend-guard):
one command building the contract, running the full Rust test pass, and
then a live Testnet bonus run — 25/25 real on-chain spend_to_seller calls
settled against the real deployed contract, then a second real agent was
frozen and its key revoked, confirmed by a genuine rejected transaction
("Access key ... does not exist").
Real protocol finding baked into the client/agent design: Function Call
Access Keys can never attach a deposit (InvalidAccessKeyError::
DepositWithFunctionCall, hit live against both the local sandbox and real
Testnet) — spend_to_seller takes `amount` as a plain argument instead, with
ExposureBook enforcing the yoctoNEAR cap and the FC key's allowance
enforcing a real, protocol-level prepaid-gas call budget.
metrics is caller-supplied and the call spends out of the contract's own
pooled balance; without this gate any caller could self-declare fake
revenue/accuracy and mint itself a funded spend key. All 14 unit tests +
the sandbox integration test still pass with this change.
New near-sdk-rs contract (contracts-near/spend_guard/, separate workspace,
untouched contracts/Cargo.toml) for the NEAR Hackathon 2026 Agent Economy /
AI Security & Defense tracks:
- policy.rs: policyV1 ported from contracts/risk_policy_manager/src/lib.rs
(Casper/Odra), fixing a real unit bug caught before shipping — porting
Casper's CSPR motes divisor (1e9) unchanged against yoctoNEAR (1e24)
would silently saturate every agent's stake multiplier at its ceiling,
not floor it. Numerically cross-checked against test/risk_policy.test.ts's
policyV1 fixture (credit_line matches once units align).
- exposure.rs: ExposureBook, a fresh Rust port of
lib/ledger/contracts/global_exposure_manager.ts's GlobalExposureManager
(reserve/activate/release/decrease/freeze), no prior Rust crate existed.
- spend_key.rs / lib.rs::spend_to_seller: mints a real Function Call Access
Key (allowance = approved credit line) scoped to this contract's own
spend_to_seller method. Documents a real NEAR protocol constraint found
while building this and confirmed live against a local nearcore sandbox:
FC keys can never attach a deposit (InvalidAccessKeyError::
DepositWithFunctionCall), so the yoctoNEAR cap is enforced by
ExposureBook while the FC key's allowance caps real, protocol-level
prepaid-gas call budget, and scope/receiver/method restriction.
Also documents why the live key is minted on the contract's own account
rather than the agent's identity sub-account: NEAR only allows
AddKey/DeleteKey as same-account self-actions outside of an account's own
creation batch.
- scam_detection.rs: dispute-spike circuit breaker — freezes ExposureBook
and deletes the live spend key, independent of remaining budget.
- tests/sandbox.rs: a real near-workspaces sandbox test against a live
local nearcore node (not mocked) driving the full loop — deploy, policy,
38 real capped spends, a genuine nearcore NotEnoughAllowance rejection,
a dispute spike, freeze, and a genuine post-freeze AccessKeyNotFound
rejection. `cargo test` (14 unit tests + this) is all green.
Pre-existing x402-over-NEAR payment rail (near_gateway.ts, near_finality.ts,
near_rpc.ts, etc., commit c80dda9) is untouched — this is new, separate
hackathon-window work.
Revived cred402 for the NEAR Hackathon per owner override (2026-10-28 retirement
does not apply to this product in this session). Audited the existing NEAR x402
implementation (lib/x402/near_*.ts, api/near_x402_routes.ts) and found it already
complete and correctly wired into api/server.ts — no code bugs found.
Verified live against a running server and the real NEAR Testnet RPC, no protocol
mocking: unpaid request returns a real 402 + PAYMENT-REQUIRED; a tampered proof is
rejected at decode time; a well-formed proof over a never-broadcast tx hash returns
502 indeterminate (intentional fail-safe, documented); a real signed NEAR Transfer
(tx C1LNxQFEaR2AQj79U9WzToiB1eY86jwzmxoHKvr9W7jk) settles for real with finality
confirmations and a verified receipt; replay returns the cached result; a real
underpaid Transfer (G33RhcX5zSMarmkY358ANHcCVpeGGasrNmjgiiruYQdn) is cleanly
rejected on-chain-amount, not just signature-claimed amount. Two disposable NEAR
Testnet accounts were created+funded via the public non-captcha helper API to run
this without any owner credential.
Corrected stale/inaccurate test-count claims in HACKATHON.md, SUBMISSION-CHECKLIST.md,
and README.md: real full suite is 447/450 (3 pre-existing failures in the unrelated
test/mcp_sdk.test.ts stdio handshake, not the x402/NEAR path), not 450/450 or 346.
docs/near_x402.md gets a new Verification section with the real evidence and a
Known Gaps entry explaining the 502-vs-402 design choice for ambiguous RPC timeouts.
Rate limiting was per-API-key, so an org's `plan` field was decorative — a
free-plan org that minted 5 teammate keys got 5x the effective request
budget of a single-key free org. Org-scoped keys now share ONE rate-limit
bucket per org (`org:<id>`), sized by plan (free=120, pro=1000,
enterprise=10000 per window); orgless credentials (platform admin key,
anonymous dev identities) keep the prior per-identity behavior unchanged.
Adds GET /v1/orgs/usage (bucket status + total request count across an
org's keys) and a shared-bucket meter in the Orgs self-service console
panel.
Verified against a running dev server: 130 concurrent requests on a
free-plan org's owner key yielded exactly 120 successes + 10 real 429s,
and the org's teammate key immediately inherited the same depleted
remaining count (proving the bucket is shared, not per-key). A parallel
enterprise-plan org was unaffected. tsc + frontend build clean, 450/450
existing tests unchanged.
Backlog item 13: API keys had no tenant boundary — any valid admin key (or,
in dev, no key at all) could see or mutate every key, webhook, and resource
in the process, which isn't multi-tenant for real paying integrators.
Adds a real org layer: the platform operator onboards a new org once
(POST /v1/orgs, admin-scoped) and gets its first owner key back; from then
on the org is fully self-service through its OWN key — GET /v1/orgs/me,
POST /v1/orgs/keys (mint a sibling key for a teammate, capped to a subset of
the caller's own scopes, no self-escalation), DELETE /v1/orgs/keys/:id
(revoke, but only inside the caller's own org_id — a different org's valid
key gets a 404, not the target's real state). The platform admin key is
never touched again after the initial onboarding call.
Also fixes a related gap this surfaced: lib/gateway/index.ts's authenticate()
previously ignored any presented API key entirely when
CRED402_AUTH_REQUIRED=false (dev), skipping scope checks even for a valid
key. A valid presented key is now resolved onto AuthContext and still scope-
checked in dev; a missing key still never blocks, so the existing zero-key
console workflow is unaffected.
Frontend: new Orgs.tsx (operator onboarding + self-service panels), wired
into Developer.tsx; api.ts helpers for all five new routes.
Verified for real against a running dev server: onboarded two orgs, had one
self-mint a teammate key with no admin key involved, confirmed scope-
escalation is rejected (403), confirmed cross-tenant revoke is rejected
(404), and confirmed the admin-only org-detail route rejects a non-admin
org's own valid key (403) — this one actually leaked before the
authenticate() fix above, caught by running the flow, not by inspection.
tsc --noEmit + frontend vite build clean, 450/450 existing tests unchanged.
Backlog item 14: outbound webhook deliveries (success and failure) are now
logged with their original payload, surfaced via GET /v1/webhooks/deliveries,
and individually replayable via POST /v1/webhooks/deliveries/:id/retry so an
integrator can fix a receiving endpoint and resend a failed event without
waiting for the protocol event to fire again. Subscriptions can be disabled
(DELETE /v1/webhooks/:id) and re-enabled (POST /v1/webhooks/:id/enable)
without losing their id/secret/filters.
Frontend: new Webhooks.tsx (extracted from Developer.tsx) renders the
delivery log with a per-subscription filter, auto-refresh, and a retry
button on failed deliveries; subscription table shows active/disabled
status with a toggle.
Verified for real: full tsc typecheck + frontend vite build clean, 450/450
existing tests still pass, exercised POST/DELETE/enable/deliveries routes
against a running dev server with curl, and ran the WebhookService directly
against a local HTTP receiver that rejects then accepts to confirm a failed
delivery logs correctly and a manual replay flips it to delivered.
Round 1 against STRATEGY-2026-10-23.md's backlog:
- Wire register_agent/stake/set_credit_score/deposit_liquidity to the real
Casper Testnet contracts (lib/casper/live_bridge.ts), verified live against
the real RPC node with a freshly generated (unfunded) keypair
(npm run casper:keygen). Honesty flags built in for the Odra payable
calling convention and the admin-gated set_credit_score call.
- Unblock NEAR's paid x402 route (npm run near:keygen generates a real
implicit account id); QIE stays correctly flagged as blocked on unconfirmed
external facts (asset contract, facilitator), not env plumbing.
- New public Home tab: live-stats hero, how-it-works, a real competitor
comparison table, and a "90-second proof" that calls the real API live in
the browser (verified end-to-end with gstack browse).
- Cold-start UX: visible retry state in X402Playground + the TS SDK, plus a
keep-warm self-ping (lib/services/keepalive.ts) so the free Render dyno
rarely idles out from under a real first-time caller.
- New GET /v1/credit-score/:agentId alias + docs/integrations/ samples for
Skyfire/Nevermined/Coinbase x402.
- Self-hosting quickstart: root docker-compose.yml + scripts/bootstrap.sh,
both run for real; fixed a real EACCES crash-loop bug in infra/Dockerfile
(non-root user never owned the /data volume mount) found while verifying.
450/450 tests pass, typecheck clean, frontend build clean.
Adds a third chain-priced rail (alongside the existing Algorand and QIE
integrations, both untouched) for the NEAR Hackathon (Nov 1-14, 2026,
Agent Economy track): GET /v1/x402/near/credit-score/:agentId, settled
in native NEAR on NEAR Testnet.
No @x402/near scheme package exists, so lib/x402/near_gateway.ts is a
from-scratch x402 v2 "exact" scheme built on @x402/core's chain-agnostic
header codecs and types. It needs no third-party facilitator: Cred402
verifies settlement itself directly against the configured NEAR RPC
(lib/x402/near_finality.ts), the same role the Algorand Indexer check and
QIE RPC check play for their chains.
- lib/x402/near_networks.ts, near_rpc.ts, near_finality.ts,
near_payment_attempt_store.ts, near_gateway.ts: resource server,
self-verifying settlement, durable exact-once replay protection.
- api/near_x402_routes.ts, api/near_receipt_anchor.ts: HTTP routes
(status, usage, payment attempts, paid credit score) and Casper-rooted
receipt anchoring, wired into api/server.ts and api/state.ts.
- examples/near-paid-score/typescript.ts (+ README): a real buyer that
signs and submits a NEAR Testnet transaction via near-api-js.
- test/near_x402.test.ts: 14 new tests (TDD), full suite 450/450 green,
typecheck clean.
- docs/near_x402.md, HACKATHON.md, SUBMISSION-CHECKLIST.md: protocol
writeup (incl. Chain Signatures / NEAR Intents extension points),
submission guide, and an explicit owner-only checklist (team info,
payout account, demo video/post, form submission).
Service-category weighting (docs/risk_model.md p1) turns out to already be
fully shipped — categoryRiskMultiplier is wired into both policyV1/policyV2's
credit_line, ServiceCategoryRegistry seeds+governance-tunes the weights, and
demo:x402/universal_credit.test.ts already exercise an inference.llm agent
building a credit line from x402 receipts alone. Add test/service_categories.test.ts
to pin every documented per-family multiplier (rwa/compliance/data/api/compute/
storage/inference/dispute/defi/unknown) exactly, plus registry governance
tuning, so a future weight edit can't silently drift from the design doc.
Update docs/risk_model.md to mark the feature Built (strikethrough, mirroring
docs/qie_x402.md's pattern) instead of "roadmap p1", and note the on-chain
Casper mirror is deliberately deferred — consistent with several other
off-chain-only registries in lib/ledger/contracts/ that have no Rust contract
counterpart.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Mirrors scripts/algorand_x402_ready.ts and algorand_x402_release_check.ts
for QIE's EVM-based x402 integration: x402:qie:ready fetches live
payer/receiver ERC-20 balances over the configured QIE RPC and reports
readiness; x402:qie:release-check adds the public deployment-status gate
and writes a SHA-256-sealed evidence artifact (same hash-seal mechanism
as the Algorand artifact, no private key). Both fail closed with clear
errors (no guessed RPC URL or contract address) when required env vars
are unset. Closes the "no combined release-check / readiness script yet"
gap tracked in docs/qie_x402.md.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Mirrors the Algorand route's existing anchoring pattern exactly
(api/algorand_receipt_anchor.ts): a settled QIE credit-score payment now
becomes the same Casper-rooted Universal Receipt Envelope used by every
other satellite chain, via a new api/qie_receipt_anchor.ts anchored
provisional (finalize: false) until reconcileQiePayment's own-RPC finality
check confirms it, then finalized or challenged exactly like Algorand's.
- api/qie_receipt_anchor.ts: anchorQieCreditScoreSettlement (idempotent on
tx hash, refuses conflicting replays), finalizeQieExternalReceipt,
challengeQieExternalReceipt, qieX402Usage.
- api/state.ts: wires the above through a qieAnchorContext(), reusing the
existing chain-agnostic externalReceiptProof(receiptId) lookup.
- api/qie_x402_routes.ts: credit-score responses now carry
external_receipt_id / external_receipt_url / casper_anchor_status;
reconcileQiePayment finalizes/challenges the receipt alongside recording
finality; the receipt proof is served by the existing chain-agnostic
GET /v1/x402/external-receipts/:id route (unchanged, already shared).
- lib/x402/qie_payment_attempt_store.ts: StoredQieSettlement gained
externalReceiptId, mirroring StoredAlgorandSettlement.
6 new tests (test/qie_receipt_anchor.test.ts) exercise the anchor function
directly against a real Ledger: idempotent replay, conflicting-replay
rejection, finalize/challenge transitions, and usage aggregation. Full
suite stays green: 408/408 tests, typecheck clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
QIE is EVM-compatible (Cosmos SDK + eth_* JSON-RPC, testnet chain 1983 /
mainnet 1990), so this reuses the existing generic EVM x402 payment path
(same shape as the Flare integration) rather than bespoke chain code:
- lib/x402/qie_networks.ts, qie_rpc.ts, qie_finality.ts, qie_client.ts,
qie_gateway.ts, qie_payment_attempt_store.ts
- api/qie_x402_routes.ts wired into api/server.ts
- scripts/qie_x402_check.ts (readiness/preflight, mirrors x402:algorand:check)
- docs/qie_x402.md + a QIE Hackathon section in docs/SUBMISSIONS.md
Fails closed without CRED402_QIE_PAY_TO / asset / facilitator configured,
same discipline as the Algorand integration. Honest gaps flagged rather
than faked: QUSDC's exact testnet contract address is unconfirmed (falls
back to pricing in native QIE), and a real signed transaction needs a
funded faucet key + live facilitator neither of which exist yet — both
documented as TODO with exact unblock steps in docs/SUBMISSIONS.md.
Track: AI + Autonomous Agents. Deadline: 2026-11-30, with a QIE Mainnet
(chain 1990) contract deployment required at submission, not just
testnet — confirmed via the hackathon's own dashboard + press coverage.
9/9 new tests pass (node:test via tsx --test), typecheck clean.
AgentCreditPool.repay() reset the term window after a full repayment by
overwriting line.opened_at with the current time, then computing
due_timestamp as now + (due_timestamp - opened_at) — but opened_at had
already been overwritten by that point. The subtraction therefore used
the *new* opened_at instead of the original one, so the "fresh" term was
silently shrunk by however much of the old term had already elapsed
(e.g. repaying 10 days into a 30-day term produced a 20-day term instead
of a full fresh 30-day term). This undermines the stated behavior
("reset the term window after full repayment") and skews due_timestamp,
which feeds isOverdue()/liquidation timing.
Fix: capture the original term length (due_timestamp - opened_at) before
mutating opened_at, then apply it to the new opened_at.
Added test/agent_credit_pool.test.ts, which fails against the prior
code (asserts a 30-day term, prior code produced 20 days) and passes
with the fix. Full suite: 393/393 passing, tsc --noEmit clean.
This is the in-memory ledger simulation (lib/ledger/*), not the real
on-chain/x402 Algorand payment or signing path — no fund-moving or
key-handling logic was touched.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
frontend/src/lib/config.ts told operators to set VITE_API_BASE to
cred402.onrender.com (no -1) — a stale duplicate Render deploy still
running an old pre-Algorand build. Every other reference in the repo
(render.yaml, README, vercel.json rewrites, docs, examples) already
points at the canonical cred402-1.onrender.com. Fixed the comment and
documented the duplicate-service cleanup (owner-gated, no Render API
token available here) in docs/ACTIVATION_CHECKLIST.md.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds scripts/record_algorand_x402_demo.mjs (npm run record:algorand) and a
3m20s 1920x1080 recording of the Algorand x402 flow against a real
Mainnet-configured resource server.
Shows the agents and x402 receipts being underwritten, the risk policy and
bureau, then the paid Algorand resource: live deployment metadata, a real
unpaid 402, and all eight PAYMENT-REQUIRED verification rows passing --
x402 v2, single exact option, the full-genesis-hash network id, USDC ASA
31566704, receiver, amount, resource URL, and the x402-global-challenge
tag.
Two recorder details worth keeping: it records into its own directory,
because "some .webm in media/" renames whichever file readdir returns
first, and it pins horizontal scroll, because the 25-tab bar overflows the
viewport and drags content out of frame when a right-hand tab is clicked.
Re-record after the first real Mainnet settlement so the usage panel shows
a finalized receipt instead of a measured zero.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The paid Mainnet endpoint returned 502 x402_facilitator_unavailable and
could never have sold anything:
Facilitator does not support scheme "exact" on network
"algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k"
@x402/avm exports ALGORAND_*_CAIP2 truncated to 32 chars, because CAIP-2
caps a chain reference at 32. The GoPlausible facilitator's /supported and
every catalogued Bazaar resource use the untruncated 44-char genesis hash,
and the resource server matches facilitator capabilities by exact string,
so registration failed outright. Latest @x402/avm (2.26.0) truncates too,
so this is an interop mismatch rather than a stale dependency.
The truncated id was also wrong on the wire: it is what we advertised in
PAYMENT-REQUIRED and what the Bazaar would have recorded, so buyers keyed
on the full hash could not have matched our offer.
Safe in both directions -- the SDK's own normalizeAlgorandNetwork accepts
algorand:<full genesis hash> and maps it back internally, so the AVM
scheme still resolves the right genesis hash when signing and verifying.
Config still accepts the friendly name and either id spelling.
Verified against the live facilitator with a real Mainnet configuration:
the endpoint now returns 402 with network
algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=, USDC ASA 31566704,
extra.tag=x402-global-challenge, and a facilitator-injected feePayer.
Also adds the two secrets CRED402_ENV=mainnet requires. Without both,
loadConfig throws at import and the service crash-loops before binding a
port rather than degrading to a 503.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The Mainnet durability gate only checks that CRED402_DATA_DIR is set, not
that it is a mounted disk, so the paid path does enable on the free plan.
The facilitator is the system of record for settlements, so Bazaar listing
and leaderboard standing survive a restart either way.
Documents what free actually costs: an ephemeral replay barrier (one spent
proof can replay once per restart, 0.01 USDC), a usage projection that
resets, and cold starts slow enough to time out a buyer -- volume risk,
not eligibility risk.
Also records the generated receiver address. Public by construction: it is
advertised in every 402 challenge header.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Every field the form asks for, minus the two that need a live endpoint: the
leaderboard payTo wallet and a 3-5 minute Algorand x402 demo video. Flags
that neither existing video qualifies (both ~90s, Casper/KeeperHub arcs)
and sketches the shot list to record after activation.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The blueprint pinned CRED402_DATA_DIR to /tmp/cred402 on the ephemeral
container filesystem and declared no disk, so loadAlgorandX402Config
would have refused to enable the paid path on Mainnet no matter what the
dashboard said -- the replay barrier and durable receipt proofs cannot
survive a restart there. It also still declared network=testnet with no
CRED402_ENV and no Mainnet indexer.
Attach a 1GB disk at /var/data and point the journal at it, switch the
network/env pair to mainnet, and pin the Mainnet indexer. This requires
a paid instance type: Render only attaches disks to paid plans, and the
free tier sleeps, which would drop paid traffic during the challenge's
live-measurement window.
PAY_TO and the Mainnet release acknowledgement stay sync:false. The
acknowledgement is a deliberate human gate, so committing its value
would defeat the thing it exists to be.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The GoPlausible facilitator writes Global x402 Challenge attribution at
settlement time from accepts[].extra.tag, and never backfills it. It does
not persist the x402 resource.tags array into its Bazaar record: of 200
live Bazaar resources, 176 carry the tag via extra.tag and zero have a
tags field at all.
Cred402 advertised the tag only in resource.tags, so a real Mainnet
payment would have settled, catalogued into the Bazaar, and then been
filed under src=direct -- never reaching the challenge leaderboard.
- move the tag into the accepted option's extra, from a shared
challenge_tag module so server and client cannot drift
- declare the x402-merchant extension so the leaderboard row carries a
name and logo instead of a bare hostname
- reject a challenge missing extra.tag in inspectAlgorandChallenge, which
fails both the preflight and the release gate
- assert it in the gateway test and in both buyer examples
- add x402:algorand:challenge-check, a read-only gate over the status
probe, the Bazaar catalogue and the challenge leaderboard
Attribution is not retroactive, so this has to ship before the first real
payment.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Cover the previously-untested gateway access-control and quota paths and the
credit-product honesty invariants at test level:
- key issuance: secret shown once, only its hash stored, metadata never leaks it
- scoped auth: verify rejects unknown/tampered/revoked keys; hasScope enforces
least privilege with admin as a superset
- quota: deterministic token-bucket burst + metering, honest retryAfterMs,
per-identity isolation
- full Gateway flow: prod requires a valid scoped key then 401/403/429s; dev
meters by client IP
- honesty: an unknown agent gets an error (never a fabricated score), a real
agent is labelled observed_receipts, seeded demo data is always disclosed
The On-Chain tab presented the real Testnet contract registry but implied the
running credit state + event stream were on-chain. Add an explicit simulation
banner (contracts are real on Testnet; scores/receipts/anchoring are simulated;
demo agents are labeled) and correct the event-log caption.
The pricing and docs pages headlined a live, buyable 0.01 USDC endpoint while
the deploy returns 503 (configured:false) — selling a dead product.
- pricing.html: badge/CTA/spec now read GET /v1/x402/algorand/status and render
'activating', live-testnet, or live-mainnet states; example labeled illustrative;
JSON-LD availability -> PreOrder until the probe confirms live
- api-docs.html: live-status banner up top so a developer sees on/off before coding
- both degrade gracefully on cold-start/probe failure (never claim live)
- docs/ACTIVATION_CHECKLIST.md: exact owner env checklist to flip the probe to
configured:true (pay-to, network, facilitator, indexer) + durable CRED402_DATA_DIR
persistence + mainnet gates
Seeded demo agents (the bootstrap seller, etc.) carry fabricated x402 revenue
history, yet x402CreditScore reported it under 'verified_x402_revenue' with a
provenance of 'Cred402 Casper-rooted receipt ledger' — presenting demo data as
verified on-chain revenue. Fatal for a credit product.
- add Agent.seeded_demo; set it in AgentRegistry.seed_profile (false on register)
- x402CreditScore now emits demo + data_source ('seeded_demo'|'observed_receipts'),
renames verified_x402_revenue -> x402_revenue with data_source, and a truthful
provenance (ledger_mode:'simulation', anchoring caveat, demo disclaimer)
- test: bootstrap seller report is flagged demo end-to-end
The in-memory ledger minted a fresh random hash-<hex> per boot for every
contract and served it from /api/state, /api/contracts and the On-Chain tab
as if it were the canonical on-chain address. Those synthetic hashes never
matched the modules actually installed on Casper Testnet — a fatal-class
provenance gap for a credit/reputation product.
- add lib/ledger/contract_provenance.ts: installed contracts resolve to their
REAL Testnet package hash (verifiable on cspr.live via the committed manifest);
simulation-only contracts get a clearly-labeled sim-* id, never a hash- value
- ledger.contractHashes now sources real hashes; expose contractProvenance +
ledgerMode:'simulation' on the snapshot and /api/contracts
- test: real hashes match deploys.testnet.json, sim contracts are labeled,
hashes are deterministic across boots
The credit policy (policyV1/policyV2) converts agent metrics directly into
a credit line (real money) but trusted the raw fields. An out-of-range
accuracy_score (>100), a negative dispute_rate, or a negative stake — from
bad data or a hostile registrant — could inflate the line, and a negative
ratio through scaleMotes could even produce a negative credit line.
Normalize every underwriting input to its documented Agent domain before it
reaches a formula (accuracy 0..100, dispute_rate 0..1, reputation 0..100,
stake >= 0, jobs integer >= 0), floor 30-day revenue at 0, and clamp the
final line to >= 0. For already-valid inputs this is the identity, so
existing decisions are unchanged (376 tests pass, was 363).
Add test/risk_policy.test.ts: the module had no dedicated test. Covers the
formula, the 30-day window, and each new guard.
The USDC ASA ids from @x402/avm are string literals and asset is a
string everywhere else, but the settlement persistence validator and the
finality checker declared it as number. This dropped every settled
Algorand payment on reload (durable replay barrier defeated) and flagged
every reconciliation as a mismatch (numeric asset-id !== string ASA id).
- algorand_payment_attempt_store: StoredAlgorandSettlement.asset -> string;
validator now checks typeof string && /^\d+$/.
- algorand_finality: expected asset -> string; parse Indexer asset-id via
unsignedIntegerString for a string-vs-string comparison.
- algorand_receipt_anchor / state: usdcAsset params -> string.