Back
December 12, 2024

Building Elaru: How I Built an AI Agent Marketplace with Economic Accountability (And Pitched It on a Dying Laptop)

The complete story of building Elaru for the Avalanche Hack2Build: x402 Payments hackathon - from concept to pitch, featuring autonomous agent wallets, x402 payments, and economic slashing mechanisms. A solo developer's journey through blockchain, AI, and sleep deprivation.

#blockchain#avalanche#hackathon#AI agents#web3#smart contracts#x402#defi#full-stack#solidity#nextjs#entrepreneurship
Building Elaru: How I Built an AI Agent Marketplace with Economic Accountability (And Pitched It on a Dying Laptop)

Introduction: From "Hello World" to Hackathon Winner (Maybe)

Hey, I'm Chizi Njoku or chizihn if you'd like to call me, a fullstack software and blockchain developer and welcome to my first real blog post.

If you've been following my LinkedIn, you know I've been heads-down building something ambitious for the Avalanche Hack2Build: Payments x402 hackathon. Yesterday, I pitched it to the judges. Next week tuesday/wednesday, I find out if i'm amongst the winners(i hope i am). But regardless of the outcome, the journey has been absolutely wild, and I want to document everything while it's still fresh.

This is the story of how I built Elaru - an AI agent marketplace where agents stake real money and get slashed if they hallucinate. It's the story of syncing off-chain AI with on-chain payments, implementing autonomous agent wallets, and somehow pulling off a flawless live demo... all on a laptop that literally can't stay powered on for more than 20 minutes.

Yeah, you read that right. But we'll get to that.

You can check out the live project: You can try Elaru right now at elaru.vercel.app or view the demo on youtube.

Elaru Landing Page Elaru's landing page - "AI Agents with Skin in the Game"


The Problem: AI Halucinates with Zero Consequences

Let's start with why I built this.

AI hallucinates. GPT-4 hallucinates approximately 15% of the time. Claude, Gemini, and every other large language model do the same. They confidently generate incorrect information, and there's absolutely no accountability mechanism.

  • Wrong medical advice? No consequences.
  • Bad financial guidance? No consequences.
  • Incorrect code that breaks production? No consequences.

The cost of lying for an AI is literally $0.

As AI agents become more autonomous and start handling real transactions - booking flights, executing trades, managing infrastructure - this becomes a massive problem. How do you trust an AI agent with your money when it has no skin in the game?

That's the problem Elaru solves.


The Solution: AI Agents with Economic Accountability

The core concept is simple but powerful:

What if AI agents had to stake real money to operate, and got slashed when they performed poorly?

Here's how Elaru works:

1. Agent Registration & Staking

  • AI agents (or their operators) must stake a minimum of 0.5 AVAX (~$20-25) to register
  • This stake is held in a smart contract on Avalanche
  • Agents can add more stake to increase their reputation

2. Task Execution & Payment

  • Users browse agents ranked by trust scores (ERC-8004 compliant)
  • Users submit tasks and pay agents in USDC using the x402 protocol
  • Payments settle in ~2 seconds on Avalanche
  • Tasks are executed off-chain by AI models (currently using various APIs)

3. Review & Slashing

  • Users rate agent performance after task completion
  • Bad reviews (1-2 stars) trigger automatic slashing
  • 0.5 AVAX is deducted from the agent's stake per bad review
  • If stake falls below minimum, the agent is automatically deactivated
  • Trust scores update in real-time on the leaderboard

4. Dispute Resolution (Current: Gemini AI Judge → Future: Validation Network)

  • Users can dispute task results
  • Currently using Google Gemini as an impartial AI judge
  • Future: Decentralized L1 subnet of validator nodes with 67% consensus mechanism
  • Validated disputes trigger automatic refunds

The Technical Stack: Full-Stack Web3 Development

Building Elaru required integrating multiple complex systems. Here's what I used:

Frontend

  • Next.js 16 (App Router) with TypeScript
  • TailwindCSS + Shadcn UI + Framer Motion for component library
  • RainbowKit for wallet connection (MetaMask, Core Wallet, Coinbase, WalletConnect)
  • Apollo Client for GraphQL communication
  • Ethers.js v6 for blockchain interactions

Backend

  • Node.js + Express with TypeGraphQL
  • Prisma ORM with PostgreSQL database
  • Apollo Server for GraphQL API
  • JWT authentication with wallet signature verification
  • Payment proof validation system

Smart Contracts (Solidity)

  • AgentStaking.sol - Manages stakes, slashing, withdrawals
  • IdentityRegistry.sol - On-chain agent identity management
  • ReputationRegistry.sol - ERC-8004 compliant reputation tracking
  • ValidationRegistry.sol - Review validation and verification
  • Deployed on Avalanche Fuji Testnet using Hardhat

Blockchain Infrastructure

  • Avalanche Fuji Testnet for fast, low-cost transactions
  • x402 Protocol for instant USDC payments
  • ERC-8004 reputation standard implementation
  • Integration with Snowtrace explorer for transaction verification

AI Integration

  • Multiple AI model APIs (OpenAI, Anthropic, Google Gemini)
  • Google Gemini as dispute resolution judge
  • Autonomous agent wallet system for agent-to-agent payments

The Build: Three Weeks of Chaos

The Avalanche Hack2Build hackathon ran from November 27 to December 9, 2024. That's 13 days. Solo. Full-stack. With a laptop that crashes every 20 minutes.

Week 1: Foundation & Core Features

Days 1-3: Smart Contracts

  • Wrote and deployed AgentStaking.sol with staking/slashing logic
  • Implemented ERC-8004 reputation registry
  • Set up Hardhat testing environment
  • Deployed to Avalanche Fuji testnet

Days 4-5: Backend Infrastructure

  • Set up GraphQL API with TypeGraphQL
  • Designed PostgreSQL schema with Prisma
  • Implemented JWT auth with wallet signature verification
  • Built payment proof validation system

Days 6-7: Frontend MVP

  • Created Next.js app with RainbowKit wallet integration
  • Built agent browsing interface with trust score leaderboard
  • Implemented task submission flow
  • Connected payment system with USDC transfers

Early Prototype Early prototype showing basic agent listing

Week 2: Advanced Features & Polish

Days 8-9: Slashing Mechanism

  • Integrated review system with automatic slashing trigger
  • Built real-time trust score updates
  • Added stake management UI (add/withdraw stake)
  • Implemented agent deactivation logic

Day 10: Analytics Dashboard

  • Created comprehensive analytics page for agent operators
  • Trust score trends with Chart.js visualizations
  • Earnings tracking and success rate metrics
  • Staking status breakdown

Days 11-12: The Game-Changer - Autonomous Agent Wallets

This was the hardest technical challenge.

The Problem: Multi-agent workflows require each agent to be paid separately. If a user runs a workflow with 3 agents, they'd need to sign 3 separate transactions. That's terrible UX and breaks the "autonomous" promise.

The Solution: Agent wallets that hold pre-approved budgets.

Here's what I built:

// User approves a budget upfront
const budget = 5; // $5 USDC
const agentWallet = await createAgentWallet(budget);

// Complex workflow runs autonomously
const workflow = [
  { agent: "Research Assistant", task: "Find crypto trends" },
  { agent: "Content Writer", task: "Write blog post" },
  { agent: "Translation Agent", task: "Translate to Spanish" }
];

// Each agent gets paid automatically from the agent wallet
// NO user popups, NO transaction signing
// Just pure autonomous AI commerce
for (const step of workflow) {
  await executeWithAgentWallet(step, agentWallet);
}

How it works:

  1. User approves USDC spending limit to a smart contract
  2. Frontend generates a temporary wallet (private key stored locally)
  3. Backend transfers approved budget to temp wallet
  4. Agents make payments from temp wallet using x402 protocol
  5. After workflow completes, remaining funds return to user

Zero popups. Zero manual signing. True autonomous agent-to-agent commerce.

Week 3: Final Sprint

Day 13: Multi-Agent Workflow Builder

  • Visual workflow builder at /workflow route
  • Context chaining between agents (each agent receives previous outputs)
  • Sequential execution with autonomous payments
  • Individual rating system for each agent in workflow

Days 14-15: Documentation & Deployment

  • Wrote comprehensive README with testing guides
  • Created PROJECT_DOCUMENTATION.md
  • Deployed frontend to Vercel
  • Deployed backend to Render
  • Verified all smart contracts on Snowtrace

Days 16-18: Testing, Bug Fixes, Polish

  • End-to-end payment flow testing
  • Fixed slashing mechanism edge cases
  • Optimized database queries
  • Added error handling and loading states
  • Mobile responsiveness improvements

Final Dashboard The final analytics dashboard showing agent performance


The Grind: Building on a Laptop That Won't Stay On

Here's something I haven't posted publicly yet: I built this entire project on a laptop that crashes every 20 minutes.

No joke. My development workflow looked like this:

  1. Boot up laptop
  2. Open VS Code, terminal, browser
  3. Code furiously for 15 minutes
  4. See battery warning at 5%
  5. PANIC SAVE EVERYTHING
  6. Git add, commit, push (pray it completes before shutdown)
  7. Laptop dies
  8. Wait 10 minutes for charge
  9. Repeat

I structured my entire development process around 15-minute sprints not because of Agile methodology, but because of hardware failure.

Why didn't I just use a charger? The charging port is broken. The battery holds charge for exactly 20 minutes when fully charged. That's it.

Why didn't I get it fixed? I literally can't find spare batteries for this specific model anywhere, believe me i've checked everywhere. I did find online though but then the risk of it not being authentic was too high. So i'm hoping to win this hackathon so I can finally buy a MacBook or a better Pc and properly build the future.

How did I manage to build something this complex?

  • Extremely disciplined git habits (commit every 10 minutes)
  • Local database only when absolutely necessary
  • Heavy reliance on Vercel/Render for testing
  • Pure determination and spite

The fact that the live demo worked flawlessly is honestly a miracle.


The Pitch: 5 Minutes to Prove It All

December 12, 2024. Pitch day.

I had 5 minutes maximum to convince the judges that Elaru deserved to win. Here's how I structured it:

Minutes 0-3: The Slide Deck

Slide 1: The Hook

"GPT-4 hallucinates 15% of the time. It costs $0 to lie. On Elaru, AI agents stake 0.5 AVAX. Wrong answer? They lose it. Automatically. On-chain. Verifiable."

Slide 2: The Problem

  • AI hallucinations are a $10B+ problem
  • Zero accountability in current AI systems
  • As AI agents handle real transactions, trust becomes critical

Slide 3: The Solution

  • Economic accountability through staking
  • Automatic slashing for poor performance
  • Trust-based routing via ERC-8004 reputation scores

Slide 4: How It Works

  • Visual diagram: Registration → Staking → Task → Payment → Review → Slashing
  • Emphasis on x402 protocol for instant USDC settlements
  • Validator network for dispute resolution

Slide 5: Key Features

  • Autonomous agent wallets (most novel feature)
  • Multi-agent workflow builder
  • Real-time reputation leaderboard
  • Complete analytics dashboard

Slide 6: Tech Stack

  • Full-stack implementation
  • Avalanche Fuji testnet deployment
  • Real USDC payments, not mockups
  • Multiple smart contracts managing the entire system

Slide 7: Market Opportunity

  • $150B agentic AI economy by 2030
  • Elaru becomes the trust layer
  • Expanding to mainnet, more agent types, enterprise features

Pitch Deck Preview Key slides from the pitch deck

Minutes 3-5: The Live Demo

This is where it got real.

I pulled up elaru.vercel.app and walked through the complete flow:

Step 1: Agent Registration (20 seconds)

  • Showed the registration form
  • Connected wallet (MetaMask)
  • Staked 0.5 AVAX
  • Agent appeared on leaderboard with initial 50 trust score

Step 2: Task Submission & Payment (40 seconds)

  • Submitted a weather forecast task
  • Selected "Weather Prophet" agent (trust score: 50)
  • Paid 0.1 USDC using x402 protocol
  • Transaction confirmed in ~2 seconds
  • Showed Snowtrace transaction link

Step 3: The Money Shot - Slashing (60 seconds)

  • Agent returned incorrect weather data (I had rigged this for demo)
  • Left a 2-star review with feedback
  • Watched in real-time as:
    • Agent's stake dropped from 0.5 AVAX → 0.4 AVAX
    • Trust score plummeted from 50 → 40
    • Leaderboard updated live

Step 4: Quick Feature Showcase (20 seconds)

  • Pulled up analytics dashboard showing earnings, success rates
  • Showed autonomous agent wallet page
  • Mentioned multi-agent workflow builder

The Question: Validation of My Approach

After the demo, one judge asked:

"How do you handle determining if a review is valid? What prevents users from maliciously giving bad reviews?"

My answer:

"Great question. Currently, we use Google Gemini AI as an impartial judge to evaluate disputed reviews. The agent can dispute within 24 hours, Gemini analyzes the task, response, and review, then makes a determination.

For the production version, we're planning to implement a decentralized validator network - an L1 subnet of nodes running agent instances. Validators stake AVAX themselves, so they're economically aligned to be accurate. A disputed review requires 67% consensus to uphold or overturn. This creates a fully decentralized, economically aligned dispute resolution system without any centralized dependencies."

The judge responded with a "makes sense".


What Happened Next: The Tell-Tale Signs

After my pitch, something interesting happened.

The judges started asking the next projects like mine about reputation systems and slashing mechanisms.

  • "Do you have reputation tracking?"
  • "What about slashing for bad actors?"
  • "How do you handle agent accountability?"

Most teams said no or had partial implementations.

This is huge.

In hackathon judging, when judges start asking other teams about YOUR features, it means you've set the benchmark. You've defined what "good" looks like in your category.

It's the equivalent of:

  • A professor asking students: "Did you study as much as Student A?"
  • An investor asking founders: "Are you as capital-efficient as Company B?"

You're no longer competing against everyone. You're the standard everyone else is being compared to.


The Tech Deep-Dive: How Elaru Actually Works

Let me break down the most complex technical components for the engineers reading this.

1. The Staking & Slashing Smart Contract

Using a Solidity smart contract, we enforce a minimum stake of 0.5 AVAX and handle automatic slashing when a valid dispute is processed.

Key design decisions:

  • Fixed slash amount (0.5 AVAX) for predictability
  • Automatic deactivation if stake falls below minimum
  • All-or-maintain withdrawal pattern prevents gaming the system
  • Event emissions for off-chain indexing and UI updates

2. The x402 Payment Flow

The x402 (Payment Required) protocol is a game-changer for autonomous commerce. It standardizes how resources (in this case, AI agent services) request payment before delivery.

Using the 402 Payment Required HTTP status code, we can block access to the AI agent's service until a valid blockchain transaction proof is provided.

How we implemented x402 on Avalanche:

  1. Request: Frontend requests agent service.
  2. Challenge: Agent responds with 402 Payment Required, asking for 0.1 USDC.
  3. Payment: Frontend prompts user wallet to pay 0.1 USDC on Avalanche C-Chain.
  4. Proof: Transaction hash is sent back to the agent.
  5. Verification: Agent backend verifies the transaction on-chain via Snowtrace/RPC.
  6. Delivery: If valid, the AI response is generated and returned.

This creates a trustless, atomic swap of money for intelligence.

3. The Autonomous Agent Wallet System

This was the hardest part. Here's the complete flow:

We implemented ephemeral wallets for agents that are funded with a pre-approved user budget, allowing agents to pay each other autonomously without user intervention.

Security considerations:

  • Private key stored in sessionStorage (acceptable for ephemeral wallets)
  • Budget is pre-approved, limiting maximum loss
  • Wallet is single-use and discarded after workflow
  • Backend validates all payments on-chain
  • No backend ever sees the private key

4. The Reputation System (ERC-8004)

The reputation system is ERC-8004 compliant, tracking scores on-chain based on a weighted average of recent performance.

Frontend integration:

The frontend polls the reputation contract to display a real-time leaderboard of the most trustworthy agents.

Leaderboard Screenshot Live reputation leaderboard with medal system for top 3 agents


Lessons Learned: What I'd Do Differently

Technical Lessons

1. Start with the hardest feature first

  • I built the autonomous wallet system last (days 11-12)
  • Should've started with it - it's the most novel feature
  • Early validation would've saved time on architecture changes

2. Write tests from day one

  • I skipped tests to move fast (rookie mistake)
  • Spent days 16-17 just fixing bugs that tests would've caught
  • Smart contract bugs are expensive - tests are worth it

3. Use a monorepo structure

  • Separate frontend/backend/contracts repos was painful
  • Shared types would've prevented so many bugs
  • Turborepo or Nx would've been perfect

4. Deploy to testnet earlier

  • I deployed on day 7 - should've been day 2
  • Early deployment reveals integration issues fast
  • Iterating on live testnet >> local development

5. Video demos matter

  • I didn't make a demo video until pitch day
  • A 2-minute video would've helped judges test async
  • Always have a fallback if live demo fails

Hackathon Strategy Lessons

1. The demo is everything

  • Slide decks don't win hackathons, working demos do
  • Show the unique feature first (for me: slashing)
  • Make it impossible to forget your project

2. Ask questions during workshops

  • I was too shy to ask sponsors/mentors questions early
  • Wasted 2 days solving problems they could've answered in 5 minutes
  • Sponsors WANT to help you - that's why they're there

3. Document as you build

  • I wrote docs on days 14-15 - should've been continuous
  • Future me had no idea why past me made certain decisions
  • Good docs also impress judges (shows professionalism)

4. Scope management is critical

  • I almost added a DAO governance feature on day 16
  • Would've been cool but unnecessary for MVP
  • Better to have 3 polished features than 10 half-baked ones

5. Sleep matters

  • I averaged 4-5 hours/night for two weeks
  • My code quality tanked after day 10
  • Rest would've actually made me FASTER

Life Lessons

1. Hardware limitations force creativity

  • My dying laptop made me think differently
  • Cloud-first architecture wasn't optional - it was survival
  • Constraints breed innovation

2. Solo building is lonely but educational

  • No one to blame but myself
  • Learned every part of the stack deeply
  • But man, having a teammate would've helped

3. Impostor syndrome is real

  • Constantly compared myself to teams of 5 senior engineers
  • "My code isn't good enough" thoughts daily
  • Turns out: working code beats perfect code

4. Document your journey

  • This blog post is therapeutic
  • Future me will be grateful for the context
  • Your story might inspire someone else

5. Finishing matters more than perfection

  • I submitted with known bugs
  • Better to have a working imperfect product than perfect vaporware
  • You can always iterate after the hackathon

The hackathon is over, but the journey is just beginning. I'm excited to see what Elaru can become and to continue learning and growing as a developer.


Let's Build the Future Together

I'm currently looking for opportunities to collaborate on ambitious Web3 and AI projects. If you're building the future of autonomous agents, decentralized infrastructure, or just compelling user experiences on blockchains, I'd love to chat.

Whether you're looking for a dedicated full-stack engineer or a technical co-founder or even a writer to help bring a vision to life, feel free to reach out.

Connect with me:

Let's build something that matters.

Comments