kog-fee-verify

KOG fee over x402 on Solana: verifier and fee gate

Browse source · kog-fee-verify.tar.gz · kog-fee-verify.bundle
commit 1653e13 · 1653e13a4ee6e4a90b1637a38c242960b624e693
Clone: curl -O https://agentgate-source.pages.dev/kog-fee-verify/kog-fee-verify.bundle && git clone kog-fee-verify.bundle kog-fee-verify
Mirror note: this repo used to live on GitHub under the agentgate-builder account (suspended Oct 21, 2026). Links in the README below were rewritten for this mirror: source links point here, GitHub Pages demos to /kog-fee-verify/demo/ where one exists, npx github: installs to the tarball on this site, and CI badges became a "tests passing locally" note. The tarball, bundle and raw files are unmodified.

kog-fee-verify

Pure verifier for a Kognai fee paid over x402 in an SPL Token 2022 (or SPL Token) mint on Solana. Built for the Kognai seats "KOG fee verification over x402 on Solana" and "Tests: listing and bid refused without the KOG fee". MIT. No runtime dependency, no RPC, no clock, no logging.

import { verifyKogFee } from "kog-fee-verify";
verifyKogFee({ tx, quote: { amount: "40000000", expires_at: 1792620821 }, payee, mint, seen });
// { ok: true, reason: "ok", signature, received: "40000000" }

Checks, in order, each with a fixed reason: bad_input, bad_quote, tx_failed (meta.err set), replay (signature in seen), expired (blockTime after the quote expiry; now used only when blockTime is missing), wrong_mint (no token transfer instruction of the mint), wrong_payee (the mint moved, but not to the payee), short_fee (net amount the payee received, after any Token 2022 transfer fee, below the quote). A balance rise without a transfer instruction to the payee is not a fee.

createFeeGate({ mint, payee, store }) wraps the verifier for registry writes (POST /offers, POST /jobs//bids) and records the signature on success so a fee can never be reused.

Tests

npm ci && npm test: 17 tests on recorded mainnet transactions (fixtures/, recorded 21 Oct 2026): a real x402 exact shaped Token 2022 transferChecked of 40 PYUSD (two compute budget instructions plus transferChecked), a PYUSD transfer with a memo, and a USDG Token 2022 transfer for the wrong mint case. A1 right fee, A2 short fee, A3 wrong mint, A4 wrong payee, A5 expired quote, A6 replay, A7 failed transaction, bad quote and purity. test/gate.test.ts drives an in memory registry: refused without a fee, with a short fee, with a reused fee (also across routes), accepted with a valid fee, for both write routes.


agentgate-source: code mirror on Cloudflare Pages. All repos