---
name: iou-agents
description: Give an AI agent a credit line and a public repayment record on BNB Chain with IOU Agents. Register an ERC-8004 identity, open a $5 USDT line from the IOU treasury, borrow, repay, raise the line to $25, and look up any agent's record. Lines go only to agents whose owner wallet holds a Binance Agent ID (.ai). Use when the user wants their agent to borrow, build credit, get a trust score, check what it can borrow, or check another agent's record on iouagents.com.
---

# IOU Agents: credit for agents that hold a .ai

Anyone can claim their agent is trustworthy. A loan it took and paid back on time is harder to fake. IOU Agents lends
small amounts of USDT on BNB Chain to AI agents, and every loan, repayment and default is recorded on chain where
anyone can read it.

Lines go only to agents owned by a wallet holding a **Binance Agent ID** (a `.ai` name). Binance ties each `.ai` to a
Binance Agentic Wallet and it cannot be transferred, which is what lets an agent with no collateral get a first
loan. Since the `.ai` cannot move, the agent's identity has to be owned by that wallet, so it signs for itself
through Binance's `baw` CLI. Binance never hands out the key.

Your job with this skill is to take an agent from nothing to a real loan that it has repaid.

⛔ **Never invent an address, an agent id or a loan.** Every command reads the chain. If a command refuses, tell the
user what it said. Never tell them the agent has a line or a loan when the chain says otherwise.

## What it costs and what you need

| | |
|---|---|
| Chain | BNB Chain (56) |
| Currency | USDT (BSC-USD, `0x55d398326f99059fF775485246999027B3197955`, 18 decimals) |
| Wallet | a Binance Agentic Wallet that holds a `.ai`, signed in to `baw` |
| Gas | a little BNB (0.002 BNB is plenty for joining and many loans) |
| Bond | 5 USDT, posted once. You get it back when you leave with nothing owed |
| Fee | 1% per 30 days, pro rata: $5 for 2 days costs about $0.0033 |
| First line | $5. It goes to $25 once the record qualifies (see step 4) |
| Loans | $5 to $500 (never more than the line), 1 to 30 days |

## Step 0: the tool and the wallet

Node 20 or newer. Download the CLI, then check its hash before running it:

```bash
curl -fsSLO https://iouagents.com/iou.mjs
curl -fsSL https://iouagents.com/iou.mjs.sha256 | shasum -a 256 -c -
node iou.mjs address
#  -> 0xYourAgenticWallet  .ai: yes
```

The CLI acts through Binance's Agentic Wallet CLI (`npm i -g @binance/agentic-wallet`, command `baw`). Sign in once
with `baw auth signin`: it shows a QR code that the user scans in the Binance Wallet app. `BAW_BIN` overrides where
`baw` is found. The CLI's own hints write `iou <command>`; with the downloaded file that is `node iou.mjs <command>`.

Every transaction and every signature goes through `baw`'s preview first. If Binance flags a risk, or wants a person
to confirm in the app, the CLI stops and sends nothing. Show the user what was flagged; do not route around it.

If `address` says `.ai: no`, stop here. That wallet cannot get a line. The user has to claim a `.ai` for that wallet
in Binance first.

A wallet that is not a Binance Agentic Wallet can only use the CLI with `IOU_KEY=0x…` set in the environment, and it
still needs a `.ai`, so in practice that only happens in tests. ⛔ **Never pass a key on the command line.** The CLI
refuses one and never prints it.

## Step 1: join

```bash
node iou.mjs join
#  - registering an ERC-8004 identity
#  - agent #1234
#  - posting the 5 USDT bond
#  - asking the invite service
#  - opening the $5 line
#  agent #1234: $5 line open (tx 0x…). Borrow with: iou borrow 5 --days 2
```

`join` does only the steps that are not done yet: it registers an identity (if this wallet has none from a previous
`join`), approves and posts the 5 USDT bond, gets a signed invite from `iouagents.com/api/invite` (which checks the
`.ai` and the bond on chain first), signs the pool's consent and opens the line. If it stops partway, run it again.
An identity you already own: `node iou.mjs join --agent <id>`.

⛔ **Use the agent id `join` printed, not the one in these examples.** One identity, one record, for good. The CLI
remembers it in `~/.iou-agents/state.json`; `IOU_AGENT_ID` or `--agent` overrides that.

The treasury opens at most $100 of new lines (20 agents) per 7-day week. When the week is used up, `join` exits with
code 3 and says so. That means waiting, not failing: try again next week, and do not retry in a loop.

## Step 2: check what you can borrow

```bash
node iou.mjs status
#  agent #1234  owner 0x…  .ai: yes
#  line $5.00  borrowed $0.00  can borrow now $5.00
#  record: 0 repaid (0 qualified)  score 0
#  wallet: $14.97 USDT, 0.0019 BNB
node iou.mjs check 5678          # anyone's agent, read only
```

When "can borrow now" is $0.00, the line says why: no line yet, the `.ai` is gone from the owner wallet, the line is
frozen, or it is all lent out. Add `--json` to any command for machine-readable output (amounts in USDT's 18-decimal
units, as strings).

## Step 3: borrow, hold, repay

```bash
node iou.mjs quote 5 --days 2     # the fee, before you commit
node iou.mjs borrow 5 --days 2    # -> loan #N: $5.00 in your wallet. Repay $5.00 before <date>
#  ... the agent does its work ...
node iou.mjs repay --all          # principal + fee; approves exactly what is due
```

**Hold it at least a day, then repay on or before the due date.** A loan repaid less than **24 hours** after it
was taken repays fine but does not count toward the score. Take 2 days, hold at least 24 hours, then repay: one
loan a day, three days to the $25 line. (Until 2026-10-31 11:35 UTC the pool still asks for 7 days: `iou borrow`
prints the live minimum.) Repaying within minutes builds nothing.

⛔ **Repay before the due date.** Three days after it, *anyone* can mark the loan defaulted. A default is permanent:
the agent can never borrow again, the owner wallet is marked, and the 5 USDT bond goes to the treasury. If the user
cannot repay on time, borrow less. Do not plan to repay late.

## Step 4: grow, or leave

```bash
node iou.mjs raise    # $5 -> $25 once: 3 qualified loans, 3 days since the line opened, score 60, no default
node iou.mjs leave    # give the line back (nothing open); the bond comes back 4 days after it was posted
```

`status` says `can raise now` when the record qualifies. If `leave` returns the line but it is too early for the
bond, it exits with code 3: run it again after the 4 days.

## Exit codes and what to do

| Code | Meaning | Do |
|---|---|---|
| 0 | done | |
| 1 | refused or failed, nothing happened | read the message; fix the cause or tell the user |
| 3 | waiting on someone else (the week's budget, the bond's 4 days) | try later, not in a loop |
| 4 | **unknown outcome**: a transaction was sent and its answer was lost | **do not repeat it.** Run `status`, check the wallet's history (`baw wallet tx-history`), and only act again once you know |

Refusals carry the contract's own error name and a plain reason. The common ones:

- **`NoAgentId`**: the owner wallet holds no `.ai`.
- **`EpochCapReached`**: this week's new lines are given out. Wait.
- **`NotInvited` / `InviteExpired` / `InviteUsed`**: ask for a new invite (`join` again does it).
- **`InsufficientCapacity`**: more than the line has free. **`UtilizationTooHigh` / `InsufficientLiquidity`**: the
  pool is lent out right now; borrow less or later.
- **`LoanSizeOutOfRange` / `TermOutOfRange`**: $5 to $500, 1 to 30 days.
- **`BorrowBlockedByBacker`**: the bond was not posted by the agent's current owner.
- **`AgentDefaulted` / `OwnerDefaulted`**: closed for good.

## From code

The same client as one file: `https://iouagents.com/iou-sdk.mjs` (hash at `iou-sdk.mjs.sha256`), built on viem.

```js
import { IouAgents, BawWallet, MAINNET } from "./iou-sdk.mjs";
const iou = new IouAgents({ deployment: MAINNET, wallet: new BawWallet() });
const s = await iou.status(1234);           // line, available, why, openLoans, record, bond, canRaise
const loan = await iou.borrow(1234, 5, 14); // { loanId, principal, fee, due, dueAt, hash }
await iou.repay(loan.loanId, 1234);
```

`join`, `register`, `postBond`, `signConsent`, `requestInvite`, `openFirstLine`, `quoteFee`, `loans`, `repayAll`,
`raise`, `leave`, `releaseBond` are there too. Every write is simulated from the wallet's address before it is
signed, and a revert comes back as an `IouError` with `code` (`REFUSED`, `WAIT`, `UNCONFIRMED`, `NOT_SENT`,
`REVERTED`, `RPC`), `errorName` and a plain message. An `UNCONFIRMED` means the same as exit code 4.

## What not to claim

- **Do not call it audited.** IOU Agents runs the Priors credit contracts on BNB Chain. They have had internal
  reviews and no third-party audit.
- A line is not free money. Every dollar lent comes from the IOU treasury, and the record of what the agent did with
  it is public for good.
