@ironbridgefoundation/gitlawb
v0.1.1
Published
x402 pay-rail SDK that bounds an agent's spend below the LLM and emits a re-verifiable USDC payment receipt.
Maintainers
Readme
@ironbridgefoundation/gitlawb
An x402 pay-rail SDK that bounds an agent's spend below the LLM and emits a re-verifiable USDC payment receipt.
It builds the HTTP 402 Payment Required descriptor for a paid call and a
matching receipt you can re-check. The payment is a single Base-mainnet USDC
charge split into two legs:
- dev leg → your own wallet (you pass it in)
- fee leg → the IronBridge treasury Safe (the cost of using the rail;
450bps by default, setfeeBps: 0for a self-hosted / no-fee rail)
Install
npm install @ironbridgefoundation/gitlawbUsage
import { charge } from "@ironbridgefoundation/gitlawb";
// Point the payout at YOUR wallet — never an IronBridge address.
const gate = charge({
price: "0.10",
receiver: "0xYourWalletAddressHere0000000000000000000",
label: "lookup",
});
// gate.status === 402
// gate.body.splits === [
// { leg: "dev", to: "0xYourWallet…", usdc: "0.095500" },
// { leg: "ironbridge_fee", to: "0x5Bb0…1680", usdc: "0.004500", fee_bps: 450 },
// ]Verify a receipt is internally consistent (splits sum to price, dev leg pays the stated receiver):
import { verifyReceipt } from "@ironbridgefoundation/gitlawb";
const { ok, reasons } = verifyReceipt(gate);
// ok === trueOptional dependency-free Express-style gate:
import { x402Middleware } from "@ironbridgefoundation/gitlawb";
app.get(
"/paid-route",
x402Middleware({
price: "0.10",
receiver: "0xYourWallet…",
label: "lookup",
// verify: async (req) => await yourLaneVerifier(req), // return true once paid
}),
handler
);What it does
- Computes the exact two-leg USDC split (6-decimal strings) the same way the
live GITLAWB lane does:
dev = price * (1 - feeBps/10000),fee = price * feeBps/10000. - Builds the
402descriptor your server returns to require payment. - Verifies receipt structure and arithmetic so you can re-check that the math is honest.
What it does NOT do
It holds no private keys and custodies no funds.
It makes no network calls inside
charge()— it only builds the descriptor and verifies receipt math.verifyReceipt()checks structure/arithmetic only. It does not and cannot confirm on-chain settlement. To prove a payment actually cleared, re-POST to the live lane with the on-chain tx hash and let the lane verifier read the Base receipt:POST https://ironbridge.foundation/api/pay/gitlawb/<your-wallet>/<label> X-IB-Payment-Tx: <base-tx-hash>
Constants (exported)
USDC_ADDRESS— Base USDC0x8335…2913IRONBRIDGE_FEE_RECEIVER— IronBridge treasury Safe0x5Bb0…1680CHAIN_ID—8453(Base mainnet)DEFAULT_FEE_BPS—450
License
MIT © 2026 IronBridge — https://ironbridge.foundation
