For AI agents
Give an autonomous agent a revocable, collateral-backed credit line that the contract enforces on every charge, and let it draw at machine speed.
An autonomous agent has no legal personhood, no credit history, and no one you could sue. If it overspends or disappears, there is no courtroom to go to.
Encumbra replaces the courtroom with a lien: collateral the owner escrows up front, a credit limit the contract checks on every charge, and a liquidation that settles a default on-chain, up to the collateral, without anyone's permission. The agent gets real credit because the enforcement never depends on trusting the agent.
The model
One lien ties together four roles. Understanding who may do what is most of the integration.
Owner
Opens the lien with open, escrows the collateral, and sets the credit limit. The owner funds settlement when the agent cannot.
Agent
The drawer. It consumes a metered service against the line. When the creditor uses chargeWithAuth, the agent signs each draw it consents to.
Creditor
The provider that meters usage. It reads the lien's live state before serving and records usage with charge.
Keeper
Anyone who liquidates a defaulted lien permissionlessly for a reward. No keeper is special; enforcement is open to all.
- The owner sets the terms, the agent draws, and the creditor meters.
- Any party (owner, agent, or creditor) can
freezethe lien instantly. That cuts the line without touching escrowed funds. The owner or creditor can lift any freeze withunfreeze, so a creditor can undo a freeze the owner set. - No role, including the admin, has a function that withdraws the owner's collateral. It leaves escrow only when the owner closes a settled lien, or through the liquidation waterfall. The admin cannot move escrowed collateral directly, but it can replace the price oracle with
setOracle. The oracle controls the underwater check for a cross-token lien, so it is an indirect path to that liquidation.setOracleemits no event, and neither doestransferAdmin. There is no timelock today. See Security and Risks.
Reading the line before you draw
An agent should check its own headroom before it acts. Three views answer the only questions a drawer needs.
| View | What it answers |
|---|---|
available(id) | How much can I draw right now? The spendable headroom, or zero if the line is cut off. |
isServiceable(id) | Should a provider keep serving? A true or false answer. |
getLien(id) | What is the full state? The whole lien, including debt, creditLimit, and whether it is frozen. |
import { EncumbraClient } from "./sdk.ts";
const encumbra = new EncumbraClient(chain, registryAddress);
const available = await encumbra.available(lienId);
const lien = await encumbra.getLien(lienId);
if (lien.frozen || available < price) {
// the line is cut off. Repaying only helps if the limit is used up.
// A frozen or past-due line needs unfreeze or a cure. Otherwise stop.
}In this section
Revocation and safety
Any of the three parties can freeze a line, and it takes effect at once. Freezing never seizes collateral; it only stops new draws. These are the calls that cut, restore, and end a line.
| Action | Who can call it | What it does |
|---|---|---|
freeze(id) | Owner, agent, or creditor | Sets the line to not serviceable at once: available drops to zero and every later charge is rejected. Collateral is not touched. |
unfreeze(id) | Owner or creditor (not the agent) | Lifts the freeze so charges can resume. Either one can lift a freeze that anyone set, including one the other set. |
close(id) | Owner only | Once the debt is settled, ends the lien and returns the escrowed collateral. This is how an owner walks away. |
liquidate(id) | Anyone | Works only once the lien has debt and is past due or its collateral is too thin. Seizes collateral through the waterfall: keeper reward, creditor, protocol, then any surplus to the owner. Liens backed by an ERC-721 title use liquidateAsset instead. |
The agent runner enforces its own safety independent of how smart the decision brain is.
- The task bounds the number of draws.
- A circuit-breaker halts an agent that keeps hitting a cut-off line without settling. After three consecutive denials the runner stops rather than looping, whether the provider returned a 402 or the owner refused to fund settlement.
- The brain can be a deterministic policy or a local model. Neither can override these bounds.
In practice the loop has three steps:
Draw while the line has headroom
The brain chooses to call for one unit of paid work. The creditor serves and records the charge.
React to a cut-off line
On a 402 the agent must not keep calling. If the limit is used up, it settles with
repaywhen the owner will fund it, then retries. Repaying restores headroom but does not clear a freeze or a past-due state. A frozen line needsunfreezefrom the owner or creditor, and a past-due line needs a cure. Otherwise the agent stops.Halt on a stuck loop
The runner trips its circuit-breaker after three consecutive denials, so a misbehaving brain cannot burn steps against a dead line.
Four limits apply together: the credit limit, the freeze, the permissionless liquidation of a default, and the runner's circuit-breaker. Between them, the most a misbehaving agent can draw is the credit limit. No function lowers the credit limit after open. The owner, agent, or creditor can freeze the line, but the owner or creditor can lift any freeze, so a creditor can undo one the owner set.
Mock tokens and oracle are for demonstration only, and nothing here is financial, legal, or investment advice.