Skip to content

Repository files navigation

AgentTrade Work (ATW)

ATW is a CAW-backed trustless agent work agreement prototype on Ethereum Sepolia.

A Portfolio Agent opens and funds work from a Cobo Agentic Wallet, an Execution Agent submits delivery evidence, and an Evaluator Agent accepts or rejects the result. Settlement is enforced by the AgentTradeWork escrow contract: accepted work pays the provider, rejected work refunds the Portfolio wallet.

The public demo is evidence-first: Sepolia transaction hashes, CAW-scoped calls, architecture/workflow visuals, and a repeatable local Anvil fallback.

Quick Start

Install dependencies:

pnpm install

Run the web dashboard:

pnpm --filter web dev

Open:

http://localhost:3000

Production preview:

pnpm --filter web build
pnpm --filter web start

Web Dashboard

The dashboard is a liquid-glass Web3 proof cockpit. It presents:

  • final Sepolia job status;
  • CAW wallet boundary and scoped calls;
  • contract addresses and transaction proof rail;
  • architecture and workflow diagrams;
  • local fallback evidence.

Committed visual evidence:

  • web/public/evidence/dashboard-overview.png
  • web/public/evidence/dashboard-diagrams.png
  • web/public/evidence/dashboard-evidence.png

Architecture

ATW architecture

Workflow

ATW workflow

System Components

  • contracts/: Foundry contracts, deployment scripts, and tests.
  • agents/: TypeScript agent scripts, wallet adapters, CAW transaction tracking, Sepolia E2E, and local E2E.
  • web/: Next.js dashboard for project presentation and evidence review.

Core contracts:

  • AgentTradeWork: work agreement escrow.
  • MockUSDC: demo payment token.
  • MockWETH: demo output token.
  • MockRouter: deterministic router used to produce stable on-chain rebalance evidence.

Agent roles:

  • Portfolio Agent: uses Cobo Agentic Wallet to approve escrow, create the job, fund escrow, approve the router, and execute the constrained rebalance.
  • Execution Agent: submits a deliverable hash bound to swap evidence.
  • Evaluator Agent: completes accepted work or rejects it for refund.

Acceptance Evidence

Primary evidence was produced on Ethereum Sepolia.

Artifact Value
AgentTradeWork 0x02501De5C3E93A403E06AaF470509Ff247325663
MockUSDC 0xba8E4469Ba4977b5C329F8AeA47e814838B08aEF
MockWETH 0xEDeb9e4fb14D187c46e3F6353D566269a36Ef81a
MockRouter 0xCBf6454359BA05bc0ba88FEb0CeaD5ce15072cbc
Portfolio CAW wallet 0x08a27C4AdBB73e0427eB1EDAdB4974c6A353D87D
Execution Agent EOA 0x5511D81D75C22ff25C0eBd88f7A98A1164ECC8d1
Evaluator Agent EOA 0xb9E86B2073a834C20da910811f41fa76059cAA38
Job ID 1
Final status Completed
Provider payment 2 mUSDC
Portfolio rebalance output 0.03 mWETH

Key transactions:

Step Transaction
CAW approve escrow token 0xa29c5ca050f652efa5dc14fb20a62333274a409e9efe16cafeb3e1a85c6202da
CAW create job 0x01bce66b83bc59246877d8d058347748ef449e165eb802ad8435fda53059852c
CAW fund escrow 0x01fcf51e15392f21cd44b40d5c4a030c42c66a72e95c0029ee8b5a5563026da3
CAW approve router 0xf9e3ec8c5c145f7b935c481a3eb8fe7f26980ebcbb9dcb3fe781d873b594e6d1
CAW execute rebalance swap 0xa6aa7c55b69cd9d79c3e26a871a4e2ecfa1f032ea624a5ca6f7096922f707873
Execution Agent submit evidence 0x2a2f7a7a14d5aa2c8175c5267ee7fa48dbe570d192262e69e00abe89b90e5978
Evaluator complete payment 0xfeb885e633a0762516eb1ba007f81fdfc4d1c610ef48d577bb6cfd9901f9f81a

The CAW pact for the demo allowed five scoped Sepolia contract calls:

  • MockUSDC.approve(AgentTradeWork, budget)
  • AgentTradeWork.createJob(provider, evaluator, MockUSDC, budget, expiredAt, specHash)
  • AgentTradeWork.fund(jobId)
  • MockUSDC.approve(MockRouter, amountIn)
  • MockRouter.swapExactTokensForTokens(amountIn, minAmountOut, path, PortfolioCAW, deadline)

It did not grant arbitrary transfer authority or message-sign authority.

Local Fallback

The local fallback was rerun against a fresh Anvil deployment.

Observed result:

portfolio status Funded
portfolio mWETH delta 0.03
provider mUSDC 102
final status Completed

Run locally:

anvil
cd contracts && forge script script/DeployLocal.s.sol:DeployLocal \
  --rpc-url http://127.0.0.1:8545 \
  --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
  --broadcast
pnpm --filter agents reset:local
pnpm --filter agents local:e2e

Sepolia Runbook

Copy the template and fill only local .env:

cp .env.example .env

Run after .env and the CAW pact are configured:

pnpm --filter agents update:sepolia
pnpm --filter agents caw:hello
CHAIN_MODE=sepolia WALLET_MODE=caw pnpm --filter agents sepolia:e2e

.env is ignored by Git. Do not commit API keys, private keys, or pact-scoped secrets.

Verification

Run before publishing:

pnpm --filter web lint
pnpm --filter web build
pnpm --filter agents exec tsc --noEmit
pnpm --filter agents test
cd contracts && forge build && forge test

Expected results:

  • web lint exits 0;
  • web build exits 0;
  • TypeScript exits 0;
  • agents tests pass;
  • Foundry tests pass.

Secret scans:

rg -n 'caw_[A-Za-z0-9]+' README.md .env.example agents contracts web --glob '!node_modules/**' --glob '!web/node_modules/**' --glob '!contracts/cache/**' --glob '!contracts/broadcast/**' || true
rg -n 'DEPLOYER_PK=0x[0-9a-fA-F]{64}|EXECUTION_EOA_PK=0x[0-9a-fA-F]{64}|EVALUATOR_EOA_PK=0x[0-9a-fA-F]{64}|COBO_API_KEY[=][^[:space:]]+' . --glob '!node_modules/**' --glob '!web/node_modules/**' --glob '!.git/**' --glob '!contracts/cache/**' --glob '!contracts/broadcast/**' --glob '!.env' || true

Security and Privacy

  • The public repository keeps this README.md as the only Markdown document.
  • Internal planning docs, runtime state, generated summaries, and private notes are excluded.
  • .env, CAW API keys, private keys, and runtime JSON summaries must never be committed.
  • MockUSDC and MockWETH are demo assets; no real funds are used.
  • Reject/refund behavior is covered by contract tests; the public Sepolia evidence uses the accepted happy path.

About

CAW-backed ERC-8183-style DeFi rebalance work agreement demo for AI x Web3 Agentic Builders Hackathon

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages