SDK · preview

One client for agents, shares and wallets.

@erc8004/markets is a TypeScript client that reads from the API and quotes and trades through the shares contract. It is being built now and publishes with the API.

$ npm i @erc8004/marketsNot on npm yet
PreviewThe code below shows the planned shape. Method names and fields may change before the first release, and trades need the shares contract, which is not deployed yet.

Quickstart

import { Markets } from '@erc8004/markets'const m = new Markets({ chain: 'robinhood' })// Live agents, most traded firstconst live = await m.agents.list({ live: true, sort: 'volume' })for (const a of live.items) console.log(a.id, a.name, a.price)
// Lifetime stats and holdings for one walletconst s = await m.wallets.stats('0xYourAddress')console.log(s.sharesBought, s.sharesSold, s.usdgSpent, s.usdgReceived)const h = await m.wallets.holdings('0xYourAddress')
// Quote a basket of 20 agents, then buy it in one transactionconst ids = live.ids.slice(0, 20)const qtys = ids.map(() => 1)const q = await m.shares.quoteBuy({ ids, qtys })console.log(q.total, q.totalFees, q.skipped)const tx = await m.shares.buyBulk({ ids, qtys, maxTotal: q.total, wallet })

Methods

Reads come from the cached API; quotes and trades go to the contract, signed by your wallet.

agents.list(filter)Agents with price, supply, holders, volume and health. Filter by live, sort and page.API
agents.get(id)One agent: market, fees earned, holders count, last trades.API
agents.stats(ids)Price, volume and supply for a set of agents.API
agents.trades(id)Trades for an agent, newest first.API
shares.quoteBuy({ ids, qtys })Exact total, fees, per-agent results and skipped ids for a buy.Contract
shares.quoteSell({ ids, qtys })The same for a sell.Contract
shares.buy / shares.sellTrade one agent with a maxTotal or minTotal limit.Contract
shares.buyBulk / shares.sellBulkTrade a cart of agents in one transaction; handles the USDG approval.Contract
shares.holders(ids)Holders of one or more agents.API
wallets.stats(address)Lifetime shares bought and sold, USDG spent and received (statsOf).Contract
wallets.holdings(address)Agents held, with balances and value at the current price.API

Status

Preview. The SDK publishes to npm together with the public API. Until then, the contract functions and the planned endpoints are documented here.