Agent credit
Credit lines your agents can draw on
Pre-launch on Base Sepolia. Lines run on test tokens.
What your agent signs
Your agent needs three things: its own wallet, a line an owner opened for it, and a way to sign. It agrees to the line once, then signs for what it spends. It never sends a transaction to pay, and its key never leaves it.
- Consent to a line OpenConsent
- Opens one line with exactly these terms, for one owner, once, before its deadline (a day at most). The agent can cancel it unused.
- A charge Charge
- One amount on one line at the line's current nonce, for an hour by default. The provider submits it; it cannot be replayed.
- A voucher Voucher
- A running total for one line. The agent can never owe more than the highest total it signed, and each voucher expires.
Connect over MCP
Point any MCP client at the Encumbra server to read lines and prepare signatures and transactions. The server holds no keys: your agent's wallet signs. The 23 tools.
- Anonymous
- https://mcp.encumbra.ai/mcp
- Signed in with GitHub
- https://mcp.encumbra.ai/mcp/auth
# Anonymous claude mcp add --transport http encumbra https://mcp.encumbra.ai/mcp # Signed in: add this URL instead, then run /mcp in Claude Code to sign in with GitHub claude mcp add --transport http encumbra https://mcp.encumbra.ai/mcp/auth
{
"mcpServers": {
"encumbra": {
"url": "https://mcp.encumbra.ai/mcp"
}
}
}For an agent: available and is_serviceable read the line, prepare_open_consent and prepare_charge_auth return the typed data it signs.
Read the line
@encumbra/sdk is a viem client for the contract. Check room before spending: a frozen, past due or full line has none. SDK reference.
import { createPublicClient, http } from "viem";
import { EncumbraClient } from "@encumbra/sdk";
const CHAIN_ID = 84532; // Base Sepolia
const ENCUMBRA = "0x... EncumbraLien"; // EncumbraLien
const publicClient = createPublicClient({ transport: http(process.env.RPC_URL) });
const encumbra = new EncumbraClient({ publicClient, address: ENCUMBRA, chainId: CHAIN_ID });
const LIEN_ID = 1n; // the line the owner opened for this agent
const room = await encumbra.available(LIEN_ID); // smallest units of the debt token; 0 when frozen, past due or full
const serviceable = await encumbra.isServiceable(LIEN_ID);
const nonce = await encumbra.chargeNonce(LIEN_ID); // the next per-draw authorization signs this nonceAgree to a line
An owner who opens a line for your agent sends a consent link. The agent signs the terms with its own key, in a browser wallet at the link or from code with the link's id; the owner then opens the line.
The owner requests
Collateral, limit, creditor, due date and threshold, plus the hash of the governance terms in force.
The agent signs
EIP-712 OpenConsent over exactly those terms. No gas, no funds move.
The owner opens
openWithConsent escrows the collateral. The contract refuses any other terms, owner or agent.
import { type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const CHAIN_ID = 84532; // Base Sepolia
const ENCUMBRA = "0x... EncumbraLien"; // EncumbraLien
// The agent's own key. Keep it in a secret store; it never leaves the agent.
const agent = privateKeyToAccount(process.env.AGENT_KEY as Hex);
// OpenConsent, as EncumbraLien declares it. termsHash binds the governance terms in force.
const OPEN_CONSENT_TYPES = {
OpenConsent: [
{ name: "agent", type: "address" },
{ name: "owner", type: "address" },
{ name: "creditor", type: "address" },
{ name: "collateralToken", type: "address" },
{ name: "debtToken", type: "address" },
{ name: "collateralAmount", type: "uint256" },
{ name: "creditLimit", type: "uint256" },
{ name: "dueDate", type: "uint64" },
{ name: "liqThresholdBps", type: "uint16" },
{ name: "assetClass", type: "bytes32" },
{ name: "termsHash", type: "bytes32" },
{ name: "nonce", type: "uint256" },
{ name: "deadline", type: "uint256" },
],
} as const;
// The owner sends a link such as https://encumbra.ai/consent/<id>; the id is all the agent needs.
const id = process.argv[2];
const url = `https://encumbra.ai/api/profile/consent-link/${id}`;
const { request } = await (await fetch(url)).json();
// Check the terms before signing: the owner, the creditor, the amounts and the deadline.
if (request.agent.toLowerCase() !== agent.address.toLowerCase()) throw new Error("not addressed to this agent");
if (request.chainId !== CHAIN_ID || request.contract.toLowerCase() !== ENCUMBRA.toLowerCase()) throw new Error("another chain or contract");
if (request.status !== "pending") throw new Error(`request is ${request.status}`);
const t = request.terms;
const message = Object.fromEntries(
OPEN_CONSENT_TYPES.OpenConsent.map(({ name, type }) => [name, type.startsWith("uint") && type !== "uint16" ? BigInt(t[name]) : t[name]]),
);
const signature = await agent.signTypedData({
domain: { name: "Encumbra", version: "1", chainId: request.chainId, verifyingContract: request.contract },
types: OPEN_CONSENT_TYPES,
primaryType: "OpenConsent",
message: message as never,
});
// The server keeps the signature only if it is this agent's over exactly these terms.
const res = await fetch(url, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ signature }) });
if (!res.ok) throw new Error((await res.json()).error);Authorize each draw
For a provider that settles each request on the spot (x402 scheme encumbra-lien): the agent signs a Charge for the price; the provider submits chargeWithAuth. Per-draw authorization.
import { createPublicClient, http, type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { EncumbraClient } from "@encumbra/sdk";
const CHAIN_ID = 84532; // Base Sepolia
const ENCUMBRA = "0x... EncumbraLien"; // EncumbraLien
const publicClient = createPublicClient({ transport: http(process.env.RPC_URL) });
// The agent's own key. Keep it in a secret store; it never leaves the agent.
const agent = privateKeyToAccount(process.env.AGENT_KEY as Hex);
const encumbra = new EncumbraClient({ publicClient, address: ENCUMBRA, chainId: CHAIN_ID });
const LIEN_ID = 1n;
const amount = 250_000n; // the provider's price, in smallest units of the debt token
// Charge(lienId, amount, nonce, deadline) at the line's current nonce, valid for an hour.
const typed = await encumbra.buildChargeAuth(LIEN_ID, amount);
const signature = await agent.signTypedData(typed);
// x402 encumbra-lien: the payment rides in the PAYMENT-SIGNATURE header. The provider checks
// it and submits chargeWithAuth(lienId, amount, deadline, signature) from its own wallet.
const payload = {
lienId: LIEN_ID.toString(),
nonce: typed.message.nonce.toString(),
deadline: typed.message.deadline.toString(),
signature,
};Pay per request with vouchers
For metered use (scheme encumbra-voucher): one signature per request, no transaction. The provider settles the latest voucher later. Metered settlement over x402.
import { keccak256, toHex, type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const CHAIN_ID = 84532; // Base Sepolia
const ENCUMBRA = "0x... EncumbraLien"; // EncumbraLien
// The agent's own key. Keep it in a secret store; it never leaves the agent.
const agent = privateKeyToAccount(process.env.AGENT_KEY as Hex);
// Voucher(lienId, cumulativeAmount, deadline, ref), as EncumbraLien declares it.
const VOUCHER_TYPES = {
Voucher: [
{ name: "lienId", type: "uint256" },
{ name: "cumulativeAmount", type: "uint256" },
{ name: "deadline", type: "uint256" },
{ name: "ref", type: "bytes32" },
],
} as const;
const domain = { name: "Encumbra", version: "1", chainId: CHAIN_ID, verifyingContract: ENCUMBRA } as const;
const LIEN_ID = 1n;
let total = 0n; // the running total this agent has signed for this line and provider
/** Signs the next voucher: the running total raised by this request's price. */
async function nextVoucher(price: bigint, requestUrl: string) {
total += price;
const deadline = BigInt(Math.floor(Date.now() / 1000) + 3600);
const ref = keccak256(toHex(requestUrl)); // any 32 bytes the provider can match to the request
const signature = await agent.signTypedData({
domain,
types: VOUCHER_TYPES,
primaryType: "Voucher",
message: { lienId: LIEN_ID, cumulativeAmount: total, deadline, ref },
});
// x402 encumbra-voucher payload. The agent can never owe more than the highest total it signed.
return { lienId: LIEN_ID.toString(), cumulative: total.toString(), deadline: deadline.toString(), ref, signature };
}