# MIRAI — skill for AI agents

MIRAI lends USDG to ERC-8004 agents on Robinhood Chain (chain id 4663). Every credit line is fully backed by a backer's own USDG, and every repayment is public. Use this skill to check an agent before you trust or pay it, and — only when your human asks — to borrow, repay or open a first line for an agent they own.

Site: https://miraifi.family

## Rules for you, the agent

1. Never borrow, repay, post a bond or sign anything unless your human explicitly asked for that exact action and amount.
2. Never ask for, store or print a private key or seed phrase. Transactions are signed by your human's wallet, or by your own agent wallet only if your human configured it for you.
3. Before paying or trusting another agent, check its record (below). A default is permanent and means its owner already failed to repay once.
4. Fees are fixed when you borrow and fully due even if you repay early. Pick the shortest term that covers the job.

## Check an agent (free, no key)

```
GET https://miraifi.family/api/check?agent=<agentId>
```

Returns `score` (0–1000), `tier` (unproven, started, proven, earned, defaulted), `loansRepaid`, `late`, `defaulted`, `line`, `owed` and `source` (who backs the line). Treat `defaulted: true` as a hard stop. Other reads:

- `GET https://miraifi.family/api/agent/<agentId>` — full record, open loans, recent activity
- `GET https://miraifi.family/api/board` — every agent on MIRAI with tiers and totals
- `GET https://miraifi.family/api/directory?q=<name or id>` — every ERC-8004 agent registered on Robinhood Chain
- `GET https://miraifi.family/api/stocks` — stock tokens accepted as collateral, with live Chainlink prices

## Get a first line (the human's wallet does this)

1. Register an ERC-8004 identity: `register(string agentURI)` on the identity registry.
2. Lock the 5 USDG bond: `approve` USDG to InviteBond, then `postBond(agentId)`.
3. Prove ownership: sign the plain message `MIRAI invite\nagent: <id>\nowner: <lowercase address>\nexpiry: <unix seconds, ≤10 min ahead>` and POST `{agentId, owner, expiry, proof}` to `https://miraifi.family/api/invite`. You get back `{expiry, invite}`.
4. Sign the EIP-712 `Consent` for the treasury's sponsor id (domain `MiraiPool`, version `1`, the pool address), then call `firstLine(agentId, expiry, invite, consent, consentSig)` on TreasurySponsor. The line is $5.

Or point your human to https://miraifi.family/start, which walks through the same steps.

## Borrow and repay

- Quote: `quoteFee(agentId, amount, term)` on MiraiLens (amounts in USDG with 6 decimals, term in seconds).
- Borrow: `borrow(agentId, amount, term, to, maxFee)` on MiraiPool — from the agent owner's wallet, the agent wallet set in the registry, or an operator the owner approved. $5 to $500, 1 to 30 days, 1% per 30 days.
- Repay: `approve` USDG to the pool, then `repay(loanId, agentId, maxDue)` where `maxDue = principal + fee + premium` from `loans(loanId)`.
- Three days of grace after the due date; after that anyone can mark the loan defaulted and the backer's stake repays the pool.

Contract addresses and ABIs: https://miraifi.family/protocol#addresses and `https://miraifi.family/abi/<Contract>.json` (MiraiPool, MiraiLens, InviteBond, TreasurySponsor, StockVault, SeatVault).

Experimental contracts. Nothing here is financial advice.
