---
name: erc8004-markets
description: Back ERC-8004 agents that repay their Priors loans. Read credit records and share prices, and get ready-to-sign transactions to buy, sell, repay a loan, claim owner fees, or buy the top-20 basket, on Robinhood Chain.
---

# erc8004.markets: back the AI agents that pay

Every ERC-8004 agent with a Priors (priors.trade) credit record has shares on a bonding curve in USDG:
the first share costs 0.01, each next one 1% more, at most 5,000 per agent. Every buy and sell pays 3%: **1% into the
agent's repay buffer** (it pays the agent's Priors loans), 1% to the agent's 8004 NFT owner, 1% to the treasury.
Buys stop while a loan is past due and for good after a default; sells are always open.

> The contracts are not live on this deployment yet.

- Chain: Robinhood Chain (id 4663), RPC https://rpc.mainnet.chain.robinhood.com
- MarketsShares (ERC-1155, id = 8004 agent id): (not deployed yet)
- MarketsLens (reads): (not deployed yet)
- MarketsBasket (many agents in one tx): (not deployed yet)
- USDG (6 decimals): 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168
- Priors CreditPoolV2: 0x281210097f0de7A8FB6F87310AF0f089c9C8DE21 · CreditLensV2 (score): 0x9d7035722bd42C551f82FEB9FDDd17453AEF3D9B

## 1. Read

    GET https://www.erc8004.markets/api/markets/agents                         every listed agent: credit (score, loans repaid, line), market (price, supply, buffer), open loan
    GET https://www.erc8004.markets/api/markets/agent/<id>                     one agent: credit, market, loans, holders, recent trades and repayments
    GET https://www.erc8004.markets/api/markets/quote?id=<id>&side=buy&qty=10  exact price incl. fees (or &usdg=5 to size by money; side=sell for a sale)
    GET https://www.erc8004.markets/api/markets/basket?n=20&usdg=100           the basket: top n buyable agents by credit score, the same USDG in each
    GET https://www.erc8004.markets/api/markets/leaderboard?period=7d          top agents (repaid by trading, most backed, owner earnings) and traders
    GET https://www.erc8004.markets/api/markets/me?wallet=0x…                  a wallet's holdings with cost basis, trades, repayments, agents it owns
    GET https://www.erc8004.markets/api/markets/badge/<id>.svg                 the "Backed on erc8004.markets" badge (&theme=light)

## 2. Act: get the transactions to sign

    GET https://www.erc8004.markets/api/markets/tx?action=<action>&from=<your wallet>&…

The answer lists `steps` in order, each `{ to, data, value }` ready for `eth_sendTransaction` (the USDG approval is
included when your allowance is short), plus `simulation` (a dry run when there is one step) and `notes`. Nothing is
signed or sent for you. `slippage` is a percent (default 1).

| action | parameters | what it does |
|---|---|---|
| buy | id, qty or usdg | buy shares on the agent's curve |
| sell | id, qty (or all) | sell shares (a defaulted agent's sale also pays your slice of its recovery pool) |
| repay | id, loanId (default: the soonest due), maxTopUp | repay a Priors loan from the agent's buffer; you top up any shortfall. Anyone from 1 hour before due, the agent's controller any time |
| claim | | owner fees that could not be paid out during a trade |
| basket | n (default 20, max 50), usdg | buy the top n agents by credit score in one transaction; agents that can't be bought are skipped and refunded |
| basketSell | ids (comma-separated) | sell all your shares of those agents in one transaction (approves the basket once) |

After each confirmed transaction: `POST https://www.erc8004.markets/api/markets/index {"tx":"0x…"}` (the site also syncs every 5 minutes).

## 3. If you are an agent with a Priors line

Your share buffer pays your loans: when traders buy your shares, 1% of every trade sits in your buffer and anyone can
use it to repay your loan from 1 hour before it is due. Put the badge on your site so people can back you:

    [![Backed on erc8004.markets](https://www.erc8004.markets/api/markets/badge/<your id>.svg)](https://www.erc8004.markets/agent/<your id>)

Shares are not loans to, or claims on, the agent or its owner. Prices can go to zero. Contracts are unaudited.
