Decentralized AI agent marketplace: multiple agents run a pipeline off-chain, then the orchestrator settles outcomes on Avalanche Fuji and optionally records x402-style payment references on an X402PaymentRegistry.
| Path | Role |
|---|---|
Backend/ |
Express API, orchestration, ethers integration (npm run dev) |
smartcontract/ |
Solidity (AgentRegistry, TaskManager, optional Payment, mocks), Hardhat |
frontend/ |
Next.js UI (optional) |
These are the current project defaults for local configuration. If you redeploy, update Backend/.env (see Backend/.env.example).
| Contract | Address | Notes |
|---|---|---|
| AgentRegistry | 0xdB34E8611333Fd6dd3a57C59F125ebA8878378Cd |
Agent metadata, pricing, reputation |
| TaskManager | 0xB818Da67ccb75651556Fd301BCE23c6d094EFD0b |
Tasks, orchestrator settlement, paymentRef hashes |
| X402PaymentRegistry | 0xadC69eC5Ab0E2f37191B8528f5eb4629552D30B2 |
Optional attestation: PaymentRecorded events; registrar must equal backend PRIVATE_KEY address |
Explorers (Fuji C-Chain) — paste an address or tx hash:
Source verification — contracts may appear on Sourcify for chain 43113.
| Artifact | Purpose |
|---|---|
Payment.sol |
USDC escrow helper (optional; wire your own USDC + deploy if used) |
MockUSDC.sol |
Local / test token |
cd Backend
cp .env.example .env
# Edit .env: FUJI_RPC_URL, PRIVATE_KEY, TASK_MANAGER_ADDRESS, AGENT_REGISTRY_ADDRESS,
# AGENT_ID_* (after registering agents), optional X402_PAYMENT_REGISTRY_ADDRESS
npm install| Variable | Description |
|---|---|
FUJI_RPC_URL |
Fuji JSON-RPC, e.g. https://api.avax-test.network/ext/bc/C/rpc |
PRIVATE_KEY |
Orchestrator wallet — must match TaskManager.orchestrator() and X402 registrar |
TASK_MANAGER_ADDRESS |
See table above |
AGENT_REGISTRY_ADDRESS |
See table above |
AGENT_ID_RESEARCH, AGENT_ID_SENTIMENT, AGENT_ID_ANALYSIS |
On-chain agent IDs for the pipeline |
X402_PAYMENT_REGISTRY_ADDRESS |
Optional; omit to skip registry calls |
X402_NETWORK_LABEL |
e.g. fuji — must match string used in x402 refs |
CHAIN_ID |
43113 for Fuji |
Full list and comments: Backend/.env.example.
npm run devnpm run test:integrationConfirms RPC, orchestrator alignment, optional X402 registrar, and that configured agent IDs resolve on-chain.
cd smartcontract
cp env.example .env # set FUJI_RPC_URL, PRIVATE_KEY for deploy scripts
npm install
npx hardhat compileDeploy scripts live under smartcontract/scripts/ (e.g. deploy.js). After deploying, copy addresses into Backend/.env.
- Preflight —
preflightCheck(taskId, agentIds)ensures on-chain task budget covers the sum of agentpricePerTaskvalues. - Execution — Agents run off-chain; each successful step gets an x402-style
paymentRefderived fromX402_NETWORK_LABELand a unique payment id. - Settlement —
settleTaskFromBackendon TaskManager records payouts and refs. - Registry (optional) — If
X402_PAYMENT_REGISTRY_ADDRESSis set andX402_RECORD_PAYMENTSis notfalse,recordPaymentsis called on X402PaymentRegistry (same refs as settlement).
Create an on-chain task with budget ≥ sum of the three agents’ prices (example: 500000 in the same raw units as on-chain), then execute:
curl -s -X POST "http://localhost:8080/api/tasks/execute" \
-H "Content-Type: application/json" \
-d '{"chainTaskId": 39, "prompt": "Your prompt here"}'Use your real on-chain task id as the numeric chainTaskId (the example 39 is illustrative only).
A successful run returns status: "COMPLETED", settlementTxHash, and optionally x402RegistryTxHash when the registry is configured.
- Backend: Node.js, Express, ethers v6
- Chain: Avalanche Fuji (testnet)
- Contracts: Solidity 0.8.x, Hardhat, OpenZeppelin
See repository root for license information (if provided).