Agent credit
Credit lines your agents can draw on
Pre-launch on Base Sepolia. Lines run on test tokens.
Serve agents on credit
An agent with a line pays your API or service by signing for each request. You settle on its line, and the debt is owed to you, backed by the owner's collateral. No prepaid balance, no card on file.
The agent signs
With each request it signs either a charge for that one price, or a voucher that raises its running total. Signing costs the agent nothing and moves no funds.
You check and serve
Your server checks the signature against the line's agent, and that the line has room: available() for a charge, voucherRoom() for a voucher. Then it serves.
You settle
A charge is submitted with chargeWithAuth before serving. Vouchers wait: one settleVouchers transaction settles the latest voucher of every line, however many requests it covers.
The owner repays
Each draw is debt on the line, owed to you and backed by the owner's collateral. Repayments are held for you in the contract until you withdraw them here. If the line goes unpaid past its due date and grace, anyone can liquidate it and your share comes first.
Checking your sign-in
Settle on a schedule
In production your server settles, not this page: keep the latest voucher per line and run this every few minutes. Settling often keeps the window between serving and settling short.
import { createPublicClient, createWalletClient, http, parseSignature, type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { encumbraLienAbi } from "@encumbra/sdk";
const ENCUMBRA = "0x... EncumbraLien"; // EncumbraLien on Base Sepolia
const publicClient = createPublicClient({ transport: http(process.env.RPC_URL) });
// The creditor's wallet: the lines must be owed to it. No agent key is involved.
const creditor = createWalletClient({ account: privateKeyToAccount(process.env.CREDITOR_KEY as Hex), transport: http(process.env.RPC_URL) });
type Stored = { lienId: string; cumulative: string; deadline: string; ref: Hex; signature: Hex };
/** Run on a schedule with the latest voucher your server kept for each line. */
export async function settle(latest: Stored[]) {
const vouchers = latest.map((p) => {
const { r, s, v, yParity } = parseSignature(p.signature);
return { id: BigInt(p.lienId), cumulative: BigInt(p.cumulative), deadline: BigInt(p.deadline), ref: p.ref, r, s, v: Number(v ?? BigInt(yParity + 27)) };
});
// Check room first: voucherRoom(id) returns (settled, maxCumulative).
const hash = await creditor.writeContract({ chain: null, address: ENCUMBRA, abi: encumbraLienAbi, functionName: "settleVouchers", args: [vouchers] });
const receipt = await publicClient.waitForTransactionReceipt({ hash });
// A voucher that cannot apply (frozen, past due, stale, over the limit) is skipped and
// reported in a VoucherRejected event; the rest settle.
return receipt;
}Pre-launch on Base Sepolia: amounts are test tokens with no value. Not an offer to lend or borrow, and not legal, tax or investment advice.