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>
8.5 KiB
QIE x402 credit-score endpoint
Cred402's QIE integration (QIE Blockchain Hackathon 3.0, "AI & Autonomous
Agents" track — hackathon.qie.digital) sells the same resource as the
Algorand integration, priced on QIE instead:
GET /v1/x402/qie/credit-score/:agentId
The endpoint returns the policy score, probability of default, risk band,
eligibility, reason codes, and verified x402 revenue — it uses the same
oracle and risk engine as the rest of Cred402 (state.x402CreditScore); the
QIE route is a payment and distribution layer, not a forked scoring model.
Why this integration is small
QIE is an EVM-compatible Layer-1 (Cosmos SDK consensus + Ethereum JSON-RPC
eth_* compatibility — the hackathon's own builder quickstart says to point
an existing Hardhat/Foundry workflow at the QIE RPC endpoint). Cred402
therefore reuses the exact same chain-agnostic @x402/core resource-server
primitives the Algorand integration uses (x402ResourceServer,
x402HTTPResourceServer, HTTPFacilitatorClient) and only swaps the
registered scheme: ExactEvmScheme from @x402/evm instead of
ExactAvmScheme from @x402/avm. No bespoke signing, encoding, or ABI code
was written — see lib/x402/qie_gateway.ts.
What research could not confirm (and how the code fails closed instead)
- QUSDC's ERC-20 contract address. QIE's stablecoin, QUSDC, is documented
at
docs.stable.qie.digitalas a 1:1 USDC-backed receipt token, but its contract address, decimals, and testnet availability were not confirmed.CRED402_QIE_ASSET_ADDRESSis therefore a required env var with no default — the route returns503until an operator supplies a real, verified token contract. It never guesses an address. - A confirmed x402 EVM facilitator for QIE. Unlike Algorand's GoPlausible
facilitator, no default/public x402 facilitator for QIE is confirmed to
exist.
CRED402_QIE_FACILITATOR_URLis therefore also required with no default. Point it at a self-hosted facilitator (built from@x402/evm'sFacilitatorEvmSigner+ExactEvmScheme) or a third-party one that verifies/settles theexactscheme oneip155:1983(testnet) /eip155:1990(mainnet). - A public Mainnet RPC endpoint. Only a testnet RPC
(
https://rpc1testnet.qie.digital/) was independently confirmed by research.CRED402_QIE_RPC_URLhas a testnet default but is required with no default on Mainnet.
Without all three configured, GET /v1/x402/qie/credit-score/:agentId
returns 503 and never advertises a placeholder receiver, a guessed token,
or an unverified facilitator as if it were real.
Configuration
export CRED402_QIE_PAY_TO=0xYOUR_EVM_ADDRESS
export CRED402_QIE_NETWORK=testnet
export CRED402_QIE_RPC_URL=https://rpc1testnet.qie.digital/
export CRED402_QIE_ASSET_ADDRESS=0xYOUR_VERIFIED_TOKEN_CONTRACT # QUSDC once confirmed
export CRED402_QIE_ASSET_SYMBOL=QUSDC
export CRED402_QIE_ASSET_DECIMALS=6
export CRED402_QIE_PRICE_BASE_UNITS=10000 # 0.01 token at 6 decimals
export CRED402_QIE_FACILITATOR_URL=https://your-facilitator.example.com
export CRED402_DATA_DIR=/var/lib/cred402
npm run start
See .env.example for every variable and its defaults.
Inspect the unpaid challenge
curl -i "http://localhost:4021/v1/x402/qie/credit-score/YOUR_AGENT_ID"
For a strict, payment-free preflight check:
export CRED402_QIE_EXPECTED_PAY_TO="$CRED402_QIE_PAY_TO"
export CRED402_QIE_EXPECTED_ASSET_ADDRESS="$CRED402_QIE_ASSET_ADDRESS"
npm run x402:qie:check -- \
"http://localhost:4021/v1/x402/qie/credit-score/YOUR_AGENT_ID"
The preflight (lib/x402/qie_client.ts) rejects anything other than exactly
one x402 v2 exact option on the selected QIE network, the configured asset
contract and receiver, a hard price ceiling, and a matching resource URL. It
never signs or submits a transaction.
Settlement and independent finality
The route uses a durable exact-once attempt ledger
(lib/x402/qie_payment_attempt_store.ts, same role as
AlgorandPaymentAttemptStore): it stores a digest, not the raw
PAYMENT-SIGNATURE, and replays the same paid response after safe retries or
restarts. Facilitator success produces a provisional settlement; Cred402
independently re-reads the transaction receipt from the configured QIE RPC
(lib/x402/qie_finality.ts) and confirms an ERC-20 Transfer log moved at
least the expected amount to the configured receiver, with a configurable
minimum confirmation depth, before calling the payment confirmed. This
plays the same role Algorand's independent Indexer check plays, since no
Indexer-equivalent REST API for QIE was confirmed by research — Cred402 reads
its own RPC directly instead of trusting the facilitator's report alone.
GET /v1/x402/qie/payments/:attemptId exposes only coarse lifecycle,
transaction, and confirmation-count data — never the paid report, payer
identity, or raw signature.
Status probe
GET /v1/x402/qie/status is free, secret-free, and never initializes the
facilitator — it mirrors /v1/x402/algorand/status.
Mainnet release checklist
- Confirm the real QUSDC ERC-20 contract address on QIE Mainnet (chain 1990)
and set
CRED402_QIE_ASSET_ADDRESSto it. - Stand up or confirm a production x402 EVM facilitator for QIE and set
CRED402_QIE_FACILITATOR_URLto its HTTPS endpoint. - Set
CRED402_QIE_RPC_URLto a trustworthy QIE Mainnet RPC endpoint and confirmeth_chainIdreturns0x7c6(1990). - Mount a persistent volume and set
CRED402_DATA_DIRto that mount. - Set
CRED402_ENV=mainnet,CRED402_QIE_NETWORK=mainnet, andCRED402_PUBLIC_URLto the public HTTPS origin. - Set
CRED402_QIE_MAINNET_RELEASE_ACKexactly toI_ACKNOWLEDGE_REAL_QUSDC_MAINNET_PAYMENTS. - Make one real external Mainnet payment and confirm the
Transferlog and confirmation depth reconcile viaGET /v1/x402/qie/payments/:attemptId. - Record the public endpoint, transaction hash, repository, and the hackathon's required fields (GitHub repo link, live demo URL, deployed contract address, track = "AI & Autonomous Agents") ahead of the 2026-11-30 submission deadline.
Known gaps vs. the Algorand integration (tracked, not hidden)
No Casper anchoring of QIE settlements yetBuilt.api/qie_receipt_anchor.tsmirrorsalgorand_receipt_anchor.ts:state.anchorQieCreditScoreSettlementturns a settled QIE payment into the same Casper-rooted Universal Receipt Envelope every other satellite chain uses (qie:<payer>identity,qie-erc20:<contract>asset), anchored provisional untilreconcileQiePayment's RPC finality check confirms it, then finalized or challenged. The credit-score response carriesexternal_receipt_id/external_receipt_url/casper_anchor_status; the proof is public atGET /v1/x402/external-receipts/:id(the same endpoint Algorand's receipts use — receipt ids are a shared content hash, not chain-specific). Covered bytest/qie_receipt_anchor.test.ts(6 tests, against a realLedger).No combined release-check / readiness script yetBuilt.scripts/qie_x402_ready.ts(x402:qie:ready) andscripts/qie_x402_release_check.ts(x402:qie:release-check) mirroralgorand_x402_ready.ts/algorand_x402_release_check.tsexactly: they fetch the unpaid challenge, then fetch live payer/receiver balances over the configured QIE RPC (eth_chainId,eth_blockNumber, ERC-20balanceOf) vialib/x402/qie_readiness.ts, andrelease-checkadditionally writes a SHA-256-sealed evidence artifact vialib/x402/qie_release.ts(same "signed" = hash-sealed, no private key, mechanism as the Algorand artifact). Both fail closed with a clear error — no guessed RPC URL or contract address — ifCRED402_QIE_CLIENT_ADDRESS,CRED402_QIE_EXPECTED_PAY_TO,CRED402_QIE_EXPECTED_ASSET_ADDRESS, or (on Mainnet)CRED402_QIE_RPC_URLare unset. Unlike Algorand's checks, there is no ALGO-style minimum-balance/opt-in/fee-buffer check: QIE's EVM "exact" scheme has no account-reserve equivalent, and the facilitator — not the payer — pays settlement gas, so that check is not invented. Covered bytest/qie_x402_ready.test.ts(mocked RPC, no live network needed to pass).- No Bazaar-style discovery listing (QIE has no confirmed equivalent catalog yet, so none was wired in to avoid overclaiming discoverability that doesn't exist).
Do not create synthetic/self-payment volume. One genuine end-to-end payment against a real facilitator and a real QUSDC (or interim test ERC-20) contract is more useful than fabricated traffic.