Skip to content

edycutjong/delegai

Repository files navigation

DelegAI Logo

DelegAI πŸ€–

The first trustless M2M delegation economy β€” 18 SDK integration points, 3-level spending hierarchy, <10s settlement, $0.00 gas.

DelegAI Landing Page

Live Demo Pitch Video Pitch Deck Built for HackQuest


MetaMask x402 1Shot Venice AI

Next.js React TypeScript Tailwind Ethereum CI


🎬 What Happens in 10 Seconds

At 3:17 AM, an autonomous AI agent needed premium market data, risk analysis, and a gasless on-chain trade β€” spending exactly $10.02 of its $50 budget without ever touching the user's wallet.

DelegAI made that possible: 3 agents, 4 delegations, 2 x402 micropayments, 1 gasless relay β€” all cryptographically constrained by ERC-7710 caveats. The user slept through it.

DelegAI Dashboard Demo

Grant β†’ Redelegate β†’ Pay β†’ Execute β†’ Settle. The full delegation chain in <10 seconds.


πŸ’‘ Why This Matters

AI agents need to spend money β€” buying compute, fetching premium data, executing trades. But trust is binary: grant full wallet access (one bug drains everything) or no access at all (the agent can't act).

DelegAI introduces scope-narrowing redelegation β€” the first trustless M2M spending hierarchy where each level gets LESS power, making the system SAFER as it scales:

User (50 USDC, 5 calls max)
  └── Master Agent (redelegates narrower scope)
      β”œβ”€β”€ Data Worker (10 USDC, 2 calls) β†’ x402 micropayments
      └── Exec Worker (10 USDC, 2 calls) β†’ 1Shot gasless relay

What's now possible: Before DelegAI, AI agents needed either full wallet access (dangerous) or no access at all (useless). DelegAI introduces the first trustless spending hierarchy where worker budgets are cryptographically enforced to never exceed master budgets via ERC-7710 caveats β€” each redelegation level NARROWS scope. Give an AI $50 and it can hire sub-agents, but none of them can spend more than you authorized.


⛓️ On-Chain Proof (Sepolia Testnet)

Deployed and funded on Ethereum Sepolia β€” every address verifiable on Etherscan:

Role Address Etherscan
User (HybridDeleGator) 0x903eF44504F9512E059DaE4228260af4795ccEBB Contract βœ… Β· Token Transfers Β· Txns
Master Agent (EOA signer) 0x4984bCedA778862655250ACb5Fe191dD65778B8b View β†—
Data Worker (EOA signer) 0x10F3a6880AB548d232606242D417FB726f009484 View β†—
Exec Worker (EOA signer) 0x4D685F37b5b3839f8cF31A5CEBE67640a3cC2356 View β†—

Architecture note: Agent EOAs sign delegations off-chain using EIP-712 typed data β€” no gas needed. Only the final settlement executes on-chain through the User's HybridDeleGator via the DelegationManager. This is why all on-chain activity (USDC transfers, contract calls) appears on the User smart account, not the agent EOAs.


πŸ—οΈ Architecture & Integration Depth

18 verified SDK integration points across 4 sponsor technologies:

Layer Technology Integration Points
Smart Accounts MetaMask Smart Accounts Kit 1.5.x createDelegation(), signDelegation(), hashDelegation(), createCaveatBuilder(), createOpenDelegation(), encodeDelegations(), decodeDelegations(), toMetaMaskSmartAccount(Stateless7702), getSmartAccountsEnvironment(), erc7710BundlerActions, erc7715ProviderActions, ScopeType, CaveatType, sendUserOperationWithDelegation
Payments x402 (@x402/core, @x402/evm) Full buyer flow + seller flow + Erc7710ExactEvmScheme + EIP-712 verification
Relay 1Shot API (OAuth2, REST) getFeeData(), sendTransaction(), getStatus()
AI Intelligence Venice AI (llama-3.3-70b) 3 reasoning calls: budget allocation, data insight, execution decision
graph TD
    U[πŸ‘€ User EOA] -->|"grantPermission(50 USDC, 5 calls)"| M[πŸ€– Master Agent]
    M -->|"redelegate(10 USDC, 2 calls)"| DW[πŸ“Š Data Worker]
    M -->|"redelegate(10 USDC, 2 calls)"| EW[πŸš€ Exec Worker]
    DW -->|"x402 payment"| API[πŸ’° Premium Data API]
    EW -->|"1Shot relay"| CHAIN[⛓️ Sepolia]
    M -->|"settle()"| U
    V[🧠 Venice AI] -->|"private LLM reasoning"| M
    V -->|"scope analysis"| DW
    V -->|"execution plan"| EW
Loading

πŸ† Sponsor Track Alignment

Track Prize Our Integration
Best A2A Coordination $3,000 3-level redelegation with parentDelegation linking β€” agents autonomously hire and scope sub-agents
Best Agent $3,000 Autonomous agent fleet: orchestrator creates sub-delegations, data worker buys data, exec worker relays transactions
Best x402 + ERC-7710 $3,000 Full buyer (createOpenDelegation + PAYMENT-SIGNATURE) AND seller (Erc7710ExactEvmScheme + EIP-712 verification)
Best Use of Venice AI $3,000 3 real LLM reasoning calls: budget allocation (orchestrator), data insight (data-worker), go/no-go decision (exec-worker)
Best 1Shot Relayer $1,000 OAuth2 auth, getFeeData, gasless sendTransaction, getStatus polling
Feedback $500 SDK_FEEDBACK.md β€” 4 constructive feedback points with code examples

πŸš€ Getting Started

Prerequisites

  • Node.js β‰₯ 20
  • npm

Quick Start

# Clone
git clone https://github.com/edycutjong/delegai.git
cd delegai

# Install
npm install

# Configure
cp .env.example .env.local
# Add your VENICE_API_KEY for real LLM reasoning (see .env.example)

# Run
npm run dev

Open http://localhost:3000 β†’ click Start Delegation to see the full 5-step flow.

Venice AI is live by default when VENICE_API_KEY is set β€” agents produce real, unique LLM reasoning on every run. Get a free key at venice.ai/settings/api.

Live Mode (Full Integration)

Set all environment variables in .env.local to enable the complete on-chain flow:

  • Real MetaMask Smart Account delegations on Sepolia
  • Real x402 micropayments with EIP-712 verification
  • Real 1Shot gasless relay transactions
  • Real Venice AI reasoning

Demo Mode (Fallback)

Set DELEGAI_DEMO=true in .env.local to run without any external dependencies. All integrations use deterministic mock data. Useful for local development only.


πŸ”€ Live Mode vs Demo Mode

DelegAI has two operational modes. Live mode is the default β€” demo mode is a fallback for development without external dependencies.

Capability Live Mode (default) Demo Mode (DELEGAI_DEMO=true)
MetaMask Smart Accounts Real createDelegation() + signDelegation() with ERC-7710 caveats on Sepolia Deterministic mock delegation chain
x402 Micropayments Real createOpenDelegation() β†’ 402 handshake β†’ PAYMENT-SIGNATURE header Accepts any signature, returns mock data
1Shot Relay OAuth2 auth β†’ getFeeData() β†’ sendTransaction() β†’ getStatus() polling Returns success after 1s delay
Venice AI βœ… Always live when VENICE_API_KEY is set (even in demo mode) Falls back to pre-scripted reasoning
EIP-7702 Real toMetaMaskSmartAccount(Stateless7702) + signAuthorization() Returns deterministic mock auth tuple
Agent Addresses Derived from real private keys, verifiable on Etherscan Deterministic placeholder addresses

For judges: The deployed URL runs with Venice AI live. Set VENICE_API_KEY when running locally for real LLM reasoning on every agent action.


βš™οΈ Environment Variables

See .env.example for the complete list with setup instructions.

Variable Purpose Required
VENICE_API_KEY Real LLM reasoning in all agents Recommended β€” get key
PRIVATE_KEY_* MetaMask Smart Account delegations Live mode
ONESHOT_API_KEY / ONESHOT_API_SECRET 1Shot gasless relay Live mode
DELEGAI_DEMO Enable mock fallback mode Optional (false by default)

πŸ§ͺ Testing & CI

npm run lint          # Next.js ESLint
npm run typecheck     # TypeScript strict check
npm run test          # Run Jest suites
npm run test:coverage # Coverage report
npm run ci            # Full CI pipeline (lint + typecheck + test)

13 test files, 182 tests, 100% coverage. CI runs on every push via GitHub Actions across Node.js [20, 22, 24].

Verification

Run the submission verification script to confirm all 18 SDK integration points and project integrity:

npm run verify
πŸ“Š Verification Output (51/51 passed)
πŸ” DelegAI β€” Submission Verification

πŸ“ Project Structure:
  βœ… README.md exists
  βœ… LICENSE exists
  βœ… .env.example exists
  βœ… ARCHITECTURE.md exists
  βœ… SDK_FEEDBACK.md exists
  βœ… DEMO_SCRIPT.md exists
  βœ… CI workflow exists

πŸ”§ Source Code:
  βœ… Orchestrator agent
  βœ… Data Worker agent
  βœ… Exec Worker agent
  βœ… Delegator (Smart Accounts Kit)
  βœ… Relay (1Shot API)
  βœ… Buyer (x402)
  βœ… Seller (x402)
  βœ… Bundler (ERC-7710)
  βœ… Venice AI client

πŸ”— SDK Integration Depth (18 points):
  βœ… createDelegation()
  βœ… signDelegation()
  βœ… hashDelegation()
  βœ… createCaveatBuilder()
  βœ… encodeDelegations()
  βœ… createOpenDelegation()
  βœ… getSmartAccountsEnvironment()
  βœ… toMetaMaskSmartAccount(Stateless7702)
  βœ… ScopeType.Erc20TransferAmount
  βœ… CaveatType.LimitedCalls
  βœ… erc7710BundlerActions()
  βœ… erc7715ProviderActions()
  βœ… Erc7710ExactEvmScheme (x402 seller)
  βœ… verifyTypedData (EIP-712)
  βœ… decodeDelegations()
  βœ… 1Shot getFeeData()
  βœ… 1Shot sendTransaction()
  βœ… Venice AI callVenice()

πŸ§ͺ Test Suite:
  βœ… delegator.test.ts          βœ… orchestrator.test.ts
  βœ… buyer.test.ts              βœ… seller.test.ts
  βœ… relay.test.ts              βœ… bundler.test.ts
  βœ… venice.test.ts             βœ… data-worker.test.ts
  βœ… exec-worker.test.ts        βœ… constants.test.ts
  βœ… events.test.ts             βœ… mock-data.test.ts
  βœ… types.test.ts

🧠 Venice AI:
  βœ… VENICE_API_KEY is set
  βœ… Venice always calls API when key present

πŸ“Š Results: 51 passed, 0 failed, 0 warnings
   SDK Integration Points: 18/18 verified
   Test Files: 13/13

βœ… DelegAI submission verification passed!

πŸ“ Project Structure

delegai/
β”œβ”€β”€ docs/                       # Documentation & assets
β”‚   β”œβ”€β”€ ARCHITECTURE.md         # 18-point integration map
β”‚   β”œβ”€β”€ DEMO_SCRIPT.md          # Demo video script
β”‚   β”œβ”€β”€ ONESHOT_SETUP.md        # 1Shot relay setup guide
β”‚   β”œβ”€β”€ SDK_FEEDBACK.md         # Feedback for SDK teams
β”‚   └── assets/                 # Generated images & thumbnails
β”œβ”€β”€ scripts/                    # CLI tools
β”‚   β”œβ”€β”€ deploy-accounts.ts      # Deploy HybridDeleGator on Sepolia
β”‚   β”œβ”€β”€ test-delegation.ts      # End-to-end delegation test
β”‚   β”œβ”€β”€ show-addresses.ts       # Show all agent Etherscan addresses
β”‚   β”œβ”€β”€ verify-submission.ts    # 51-check submission verification
β”‚   β”œβ”€β”€ bench.ts                # Performance benchmarks
β”‚   β”œβ”€β”€ verify-demo.ts          # Demo mode verification
β”‚   └── check-submission.ts     # Submission readiness check
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                    # Next.js 16 App Router
β”‚   β”‚   β”œβ”€β”€ page.tsx            # Landing page
β”‚   β”‚   β”œβ”€β”€ dashboard/          # Delegation command center
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ delegate/       # Delegation CRUD API
β”‚   β”‚   β”‚   β”œβ”€β”€ events/         # Server-Sent Events endpoint
β”‚   β”‚   β”‚   β”œβ”€β”€ premium-data/   # x402-protected data (market-feed, defi-yields)
β”‚   β”‚   β”‚   └── relay/          # 1Shot relay webhook
β”‚   β”‚   └── globals.css         # Tailwind v4 + design tokens
β”‚   β”œβ”€β”€ components/             # React 19 components
β”‚   β”‚   β”œβ”€β”€ DelegationTree      # Hierarchical chain viz
β”‚   β”‚   β”œβ”€β”€ AgentCard           # Agent status cards
β”‚   β”‚   β”œβ”€β”€ BudgetMeter         # Budget consumption bars
β”‚   β”‚   β”œβ”€β”€ ActivityFeed        # Live event log
β”‚   β”‚   β”œβ”€β”€ AddressBadge        # Truncated address display
β”‚   β”‚   └── CaveatBadge         # Caveat type indicators
β”‚   β”œβ”€β”€ agents/                 # Agent logic
β”‚   β”‚   β”œβ”€β”€ orchestrator        # Master Agent
β”‚   β”‚   β”œβ”€β”€ data-worker         # x402 buyer
β”‚   β”‚   └── exec-worker         # 1Shot executor
β”‚   β”œβ”€β”€ lib/                    # Shared utilities
β”‚   β”‚   β”œβ”€β”€ delegator           # Smart account + delegation
β”‚   β”‚   β”œβ”€β”€ relay               # 1Shot API client
β”‚   β”‚   β”œβ”€β”€ buyer               # x402 buyer flow
β”‚   β”‚   β”œβ”€β”€ seller              # x402 seller setup
β”‚   β”‚   β”œβ”€β”€ bundler             # ERC-7710 bundler actions
β”‚   β”‚   β”œβ”€β”€ venice              # Venice AI client
β”‚   β”‚   └── events              # SSE event emitter
β”‚   └── __tests__/              # Jest test suites (13 files, 100% coverage)
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ icon.svg                # DelegAI logo
β”‚   └── pitch/                  # Pitch deck (HTML)
β”œβ”€β”€ .env.example                # Environment template
β”œβ”€β”€ .github/                    # CI workflows
└── README.md                   # You are here

πŸ“„ License

MIT Β© 2026 Edy Cu

πŸ™ Acknowledgments

Built for the MetaMask Smart Accounts Kit Γ— 1Shot API Γ— Venice AI Dev Cook Off on HackQuest. Thank you to MetaMask, 1Shot, Venice AI, and the x402 team for the SDK access and documentation.

About

πŸ€– The first trustless M2M delegation economy β€” 18 SDK integration points, 3-level spending hierarchy, <10s settlement, zsh.00 gas.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors