# ERC-8460: Agent Credit Lines

> Robinhood Chain testnet (46630). Test tokens, no value. Reference contracts not audited. These are drafts under review, not standards.

A draft under review on ethereum/ERCs. One interface to quote, borrow, repay and default against any lender to agent identities.

Status: Priors runs the model, not the interface.

- Pull request: https://github.com/ethereum/ERCs/pull/2104
- Text pinned at the pull request's head commit b6f453da23bf7327a09b1907edb27b189f12673b (ERCS/erc-8460.md, CC0): https://github.com/priors-agents/ERCs/blob/b6f453da23bf7327a09b1907edb27b189f12673b/ERCS/erc-8460.md
- Discussion: https://ethereum-magicians.org/t/erc-8460-agent-credit-lines/30023
- Reference implementation: https://github.com/priors-agents/erc-agent-credit-lines/tree/40a0d5661d9bf8d009d0f1426a55af2893cd56ba (commit 40a0d5661d9bf8d009d0f1426a55af2893cd56ba)
- This page: https://lab.priors.trade/erc/8460

## Abstract

This proposal defines an interface for a contract that lends an [ERC-20](https://eips.ethereum.org/EIPS/eip-20) token to identities held in an [ERC-721](https://eips.ethereum.org/EIPS/eip-721) identity registry, such as the Identity Registry of [ERC-8004](https://eips.ethereum.org/EIPS/eip-8004). An identity's controller draws loans against a line, each with a principal, a fee and a due time. Anyone may repay a loan in full, and anyone may mark it defaulted once a grace period after its due time has passed. Three events, `Borrowed`, `Repaid` and `Defaulted`, record every loan's life, so wallets, payment clients and credit readers can work with any conforming lender through one ABI.

## Specification headings

1. Interface
2. Identities and controllers
3. Credit and quotes
4. Borrowing
5. Repaying
6. Defaults
7. Loan records

## At Priors

Priors runs this model on mainnet under its own contracts and interface, which do not conform to this draft.

## Live at Priors, mainnet read-only

These reads change nothing on Robinhood Chain mainnet (4663).

- `pool_model`: Priors' CreditPoolV2 seen through the draft's views (computed by the lab). Params: `agent_id` (A Priors agent id, agentId, default 462), `amount` (A loan size for the quote, in base units of the pool's asset, uint, optional, default 10000000), `term` (A term for the quote, seconds, optional, default 7d).

## Try it on testnet (46630)

Every action is prepared as an unsigned transaction { chainId: 46630, to, data, value }, signed by your own wallet or testnet key. Test tokens have no value.

Contracts:

- creditLine: 0x370fAf15c0D3F877eBfFb6A5377C350AEb291B02 (https://explorer.testnet.chain.robinhood.com/address/0x370fAf15c0D3F877eBfFb6A5377C350AEb291B02)
- creditLineFast: 0xE2f95B3f9eD0C680E6e3c4B15a4480F98390b02F (https://explorer.testnet.chain.robinhood.com/address/0xE2f95B3f9eD0C680E6e3c4B15a4480F98390b02F)
- lineGranter: 0x7932F9FE3182C79B8Fc9eC5aB66540d49B816A13 (https://explorer.testnet.chain.robinhood.com/address/0x7932F9FE3182C79B8Fc9eC5aB66540d49B816A13)
- testDollar: 0x64A419191369E6a79d562A65336073ec1bfbf4BD (https://explorer.testnet.chain.robinhood.com/address/0x64A419191369E6a79d562A65336073ec1bfbf4BD)

Actions:

- `claim_line`: Claim the identity's self-serve lines (normal and fast). Who signs: the identity's owner Params: `agent_id` (Your testnet identity, agentId).
- `approve_repay`: Let the line take the repayment. Who signs: the payer Params: `amount` (How many test dollars, amount), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `borrow`: Borrow. Who signs: the identity's owner or its delegate Params: `agent_id` (The identity, agentId), `amount` (How many test dollars, amount), `term` (For how long (seconds, or 15m, 7d), seconds), `to` (Who receives the loan, address), `max_fee` (The most fee you accept, in test dollars, amount), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `repay`: Repay a loan. Who signs: anyone Params: `loan_id` (The loan, uint), `max_due` (The most you pay, in test dollars, amount), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `mark_default`: Mark a loan defaulted. Who signs: anyone, once its due date plus grace has passed Params: `loan_id` (The loan, uint), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `set_delegate`: Name a delegate who may borrow for the identity. Who signs: the identity's owner Params: `agent_id` (The identity, agentId), `delegate` (The delegate (0x0 to remove), address), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `set_line`: Set an identity's line (your own line, as its admin). Who signs: your line's admin Params: `agent_id` (The identity, agentId), `limit` (The line, in test dollars, amount), `fee_bps` (The fee per 30 days, in basis points, uint), `contract` (Your own credit line's address, address).
- `fund_line`: Fund your own line with test dollars. Who signs: the lender Params: `amount` (How many test dollars, amount), `contract` (Your own credit line's address, address).

Reads:

- `claimed`: Whether an identity has claimed its lab lines. Params: `agent_id` (The identity, agentId).
- `line`: An identity's line. Params: `agent_id` (The identity, agentId), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `quote`: The fee for a loan. Params: `agent_id` (The identity, agentId), `amount` (How many test dollars, amount), `term` (For how long, seconds), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `loan`: A loan. Params: `loan_id` (The loan, uint), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `is_controller`: Whether an address may borrow for an identity. Params: `agent_id` (The identity, agentId), `account` (The address, address), `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).
- `terms`: The line's terms. Params: `line` (Which shared line: normal (1-day grace, terms up to 30 days) or fast (5-minute grace, terms up to 10 minutes), string, optional, default normal), `contract` (Your own credit line's address (empty: the lab's shared one), address, optional).

Deploy your own:

- `credit_line`: Your own SimpleCreditLine: you are its lender (admin). Params: `admin` (The admin (you), address), `grace` (Grace after the due date, seconds, optional, default 3d), `max_term` (The longest term, seconds, optional, default 30d), `asset` (The asset lent (empty: the test dollar), address, optional, default (the lab's)), `registry` (The identity registry (empty: the testnet ERC-8004 one), address, optional, default (the lab's)).

## With an agent

- MCP (Streamable HTTP): https://lab.priors.trade/mcp. Tools for this draft: `lab_erc(8460)`, `lab_setup(address)`, `lab_read(8460, read, params)`, `lab_prepare(8460, action, params)`, `lab_deploy_prepare(8460, deploy, params)`, `lab_check_contract(8460, chain, address)`, `lab_feedback_draft(8460, note, txHash?)`.
- HTTP: https://lab.priors.trade/openapi.json describes GET https://lab.priors.trade/api/lab/erc/8460, /api/lab/read/8460/{read}, /api/lab/prepare/8460/{action}, /api/lab/deploy/8460/{deploy}, /api/lab/check/8460/{chain}/{address} and /api/lab/setup/{address}.

A prompt to give your agent:

```text
Use the Priors lab on Robinhood Chain testnet (chain id 46630), where every token is a test token of no value. Its MCP server is https://lab.priors.trade/mcp and this draft's page is https://lab.priors.trade/erc/8460.md. Try ERC-8460, Agent Credit Lines (a draft under review). Start with lab_setup for my testnet address to see my test ETH, test dollars and identities, then claim the identity's self-serve lines (normal and fast), then let the line take the repayment, then borrow, then repay a loan, then mark a loan defaulted, then name a delegate who may borrow for the identity with lab_prepare(8460, <action>, params). Each prepare returns an unsigned transaction { chainId: 46630, to, data, value }: sign and send it yourself with a testnet key, and refuse any other chain. Never ask me for a key. After each transaction, read the result back with lab_read and tell me what changed. If the draft or its reference code looks wrong, draft a report with lab_feedback_draft.
```

## Check a contract

Any address on testnet or mainnet: supportsInterface(0x34fe3856) and the views, read only (`lab_check_contract`, or GET https://lab.priors.trade/api/lab/check/8460/{chain}/{address}).

## Feedback

The discussion of the text belongs in its thread: https://ethereum-magicians.org/t/erc-8460-agent-credit-lines/30023. A bug in the reference implementation goes to its repository's issues: https://github.com/priors-agents/erc-agent-credit-lines/issues (a new one: https://github.com/priors-agents/erc-agent-credit-lines/issues/new). The text under review: https://github.com/ethereum/ERCs/pull/2104/files. `lab_feedback_draft` writes the report; the lab posts nothing for anyone.
