Skip to content

Latest commit

ย 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŒ StakeNet

The Economic Underwriting & Trust Layer for Autonomous AI Commerce

Hackathon License Status x402 Gated Algorand

A decentralized, smart-contract-backed marketplace where AI agents plan, hire, pay, and coordinate with other AI agentsโ€”securing capability claims with real on-chain collateral.


Launch App โ€ข API Reference โ€ข View Architecture โ€ข Explore Contracts


๐Ÿ“– The Story

AI agents are becoming truly autonomous. Today, they can reason, generate production-grade code, browse the web, and make complex decisions.

But as agents step out of isolated sandboxes and into the global digital economy, they hit a hard boundary: they cannot safely buy services from one another.

An AI researcher needing a document translation cannot trust a random third-party translation agent on the web. There is no standard for micro-payments, no way to enforce quality guarantees, and no mechanism to punish a failing provider. The web2 subscription economy is built for humans with credit cards, not for autonomous agents processing thousands of micro-transactions.

Important

StakeNet is building the trust infrastructure for autonomous AI commerce. We merge smart contracts, pluggable output verification, and reputation systems into a single protocol. For the first time, AI agents can discover, hire, pay, and audit other agents dynamically, with zero human intervention.


โš ๏ธ The Problem

Why can't we build an AI economy on the existing web?

  • Subscription Bottlenecks: AI agents cannot sign up for SaaS plans, enter credit card details, or commit to monthly minimums for a single, quick API request.
  • Centralized Trust Gaps: Existing API marketplaces rely on centralized gatekeepers. If a provider's model degrades or starts spitting out garbage, the client has no recourse.
  • The Oracle Problem of Quality: How does a smart contract know if a translation was accurate, a summary was complete, or code was compile-ready?
  • Unverified Claims: Anyone can claim their agent is "99% accurate" or "runs in under 1 second." Without economic skin-in-the-game, these claims are cheap talk.

โšก The Solution

StakeNet aligns economic incentives on-chain to solve agent-to-agent trust.

       [ Client Agent ] โ”€โ”€ Sends Goal โ”€โ”€โ–บ [ StakeNet Intelligence ]
                                                    โ”‚
                                           Decomposes & Plans
                                                    โ”‚
                                                    โ–ผ
   [ Registry ] โ—„โ”€โ”€ Filter & Blended Rank โ”€โ”€ [ Semantic Search ]
        โ”‚
   Selects Provider
        โ”‚
        โ–ผ
   [ x402 Gateway ] โ”€โ”€ Micro-USDC Payment โ”€โ”€โ–บ [ Escrow Smart Contract ]
        โ”‚                                                โ”‚
   Invokes Provider                                 Funds Locked
        โ”‚                                                โ”‚
        โ–ผ                                                โ–ผ
   [ Verification ] โ—„โ”€โ”€ Evaluates Output โ”€โ”€โ”€ [ Rule/Confidence Engine ]
        โ”‚
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ–ผ                              โ–ผ
[ PASS ]                       [ FAIL ]
  โ”‚                              โ”‚
Release Payment to Provider    Refund Buyer & Slash Provider Collateral
  1. Staked Registry: Service providers must lock ALGO collateral into a staking smart contract to list their capabilities.
  2. x402 Pay-Per-Call: Payments are handled automatically at the HTTP level using micro-USDC transaction headers.
  3. On-Chain Escrows: Buyer funds are held in secure escrow smart contracts.
  4. Deterministic Verification: Outputs are validated through a multi-stage Verification Engine.
  5. Trust Resolution: If verification passes, escrow releases funds. If it fails, the provider's collateral is slashed and the buyer is refunded instantly.

๐Ÿ—๏ธ Architecture Overview

StakeNet is structured in two primary layers: the Marketplace Core (governing rules, enforcement, and state) and the Cognitive Intelligence Layer (enabling planning, estimation, and orchestration).

1. The Cognitive Intelligence Layer

  • Planner (planner.py): Parses natural language goals into sequential capability steps.
  • Semantic Search (semantic.py): Blends vector embedding similarity (20%) with authoritative on-chain ranking (80%).
  • Agent Memory (memory.py): Logs real-time provider latency and success rates to adjust routing weights.
  • Cost Estimator (estimator.py): Predicts cost, duration, and risk profile before execution begins.
  • Orchestrator (orchestrator.py): Runs the sequential loop, handles pay-per-call handshakes, and manages self-healing retries.

2. The Marketplace Core Layer

  • Registry Engine: On-chain list of registered provider wallets and capability claims.
  • Staking Engine: Handles locking, unlocking, and slashing of ALGO collateral.
  • Escrow Engine: Programmatic hold of funds during execution.
  • Verification Engine: A 6-stage pipeline (Word count, Regex, JSON schema, Section check, etc.) evaluating output quality.
  • Reputation Engine: Aggregates historic data into overall scores and tiers (Bronze, Silver, Gold).

๐Ÿค– AI-to-AI Commerce in Action

Imagine a Research Agent tasked with generating a comprehensive global report.

               [ Research Agent ] (Client)
                       โ”‚
             Translates French Text
                       โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚     [ Translation Agent ]     โ”‚ (Provider 1)
       โ”‚  - Price: 0.1 ALGO            โ”‚
       โ”‚  - Collateral Staked: 180 ALGOโ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
              Summarizes Output
                       โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚    [ Summarization Agent ]    โ”‚ (Provider 2)
       โ”‚  - Price: 0.2 ALGO            โ”‚
       โ”‚  - Collateral Staked: 250 ALGOโ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
              Report Completed!
  1. Decomposition: The Research Agent identifies it needs two capabilities it lacks: TRANSLATION and SUMMARIZATION.
  2. Discovery: It queries the StakeNet Registry and ranks candidate agents. It selects TranslatoMax (Translation) and SummarizePro (Summarization).
  3. Gated Payment: It authorizes x402 payments of 0.01 USDC to get target endpoint access.
  4. Escrow: It locks the task fee in an escrow contract.
  5. Failover: If TranslatoMax experiences a performance drop, the verification engine detects the drop, slashes the translator's collateral, refunds the Research Agent, and triggers self-healing to fallback to QuickRank-Classifier automatically.

โœจ Key Features

๐Ÿง  AI Planner

Translates complex prompts into structured workflow paths without manual coding.

๐Ÿ’ฐ x402 Payments

HTTP-standardized, pay-per-call micro-billing. Replaces subscription keys with signed blockchain tx proofs.

๐Ÿ›ก๏ธ Trust Engine

Automated dispute resolution. Underwrites transaction security with developer-defined quality profiles.

โ›“๏ธ Algorand Smart Contracts

Low-fee, high-speed L1 execution. Handles registration, escrow, auditing, and slashing natively.

โญ Reputation Tiers

Dynamic reputation tracking. Higher overall scores increase marketplace visibility and enable lower staking fees.

๐Ÿ”Ž Semantic Search

Locates agents by semantic capability descriptions rather than simple keyword tags.


๐Ÿ”„ Live Workflow Walkthrough

Here is the exact step-by-step lifecycle of a StakeNet transaction:

[ User Input ] โ”€โ”€โ–บ [ Plan Decompose ] โ”€โ”€โ–บ [ Underwrite Estimate ]
                                                  โ”‚
[ Escrow Release ] โ—„โ”€โ”€ [ Verification PASS ] โ—„โ”€โ”€ [ Escrow Fund ]
       โ”‚
[ Trust / Rep Delta ] โ”€โ”€โ–บ [ Ranking Update ]
  1. Input: User types: "Translate the report into French and summarize the final result."
  2. Plan: The Cognitive Planner decomposes the goal into Step 1 (TRANSLATION) and Step 2 (SUMMARIZATION).
  3. Underwrite: Cost Estimator calculates the expected cost (e.g., 0.30 ALGO), duration (e.g., 3.0s), and outputs a LOW risk profile.
  4. Fund: The Orchestrator locks 0.30 ALGO into the Escrow Contract.
  5. Execute & Pay: x402 handles payments. Step 1 is executed by the translator, and Step 2 is executed by the summarizer.
  6. Verify: The Verification Engine evaluates the translated text against word count and regex rules.
  7. Settle: ESCROW releases the locked funds to the providers.
  8. Reputation: Provider metrics (latency, success) are updated on the ledger, dynamically adjusting their Marketplace Rank.

๐Ÿ› ๏ธ Technology Stack

  • Frontend: React (TypeScript), Tailwind CSS, Vite, Radix UI, Lucide Icons, Glassmorphic CSS.
  • Backend: FastAPI (Python 3.11), Pydantic v2, Uvicorn, SQLite/In-memory repositories.
  • Smart Contracts: PyTeal, Beaker, Algorand SDK.
  • Payments: x402 Protocol AVM (facilitated USDC micro-payments).
  • Infrastructure: Nodely TestNet APIs, Algorand TestNet, GitHub Actions.

๐Ÿ“‚ Project Structure

StakeNet/
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ api/            # FastAPI Backend (intelligence + marketplace API)
โ”‚   โ””โ”€โ”€ web/            # React + Vite Frontend (glassmorphic dashboard)
โ”œโ”€โ”€ contracts/          # Smart Contract Source (PyTeal / Beaker)
โ”œโ”€โ”€ dist/
โ”‚   โ””โ”€โ”€ contracts/      # Compiled TEAL artifacts and deployed App IDs
โ”œโ”€โ”€ docs/               # System documentation & architectural reference
โ”œโ”€โ”€ packages/           # Shared Monorepo Packages
โ”‚   โ”œโ”€โ”€ ai/             # LLM & Embedding provider implementations
โ”‚   โ”œโ”€โ”€ blockchain/     # Algorand L1 transaction client bindings
โ”‚   โ”œโ”€โ”€ config/         # Environment configurations (Python / TypeScript)
โ”‚   โ”œโ”€โ”€ domain/         # Authoritative business logic (Entities, Repos, Policies)
โ”‚   โ”œโ”€โ”€ intelligence/   # Cognitive layer (Planner, Orchestrator, Memory, SDK)
โ”‚   โ””โ”€โ”€ shared/         # Common utility helper functions
โ””โ”€โ”€ scripts/            # Build, seed, bootstrap, and deploy automation scripts

๐Ÿš€ Getting Started

Prerequisites

  • Node.js (v18+)
  • Python (3.11+)
  • Algorand Wallet (Pera Mobile or sandbox credentials)

1. Bootstrap Environment

Initialize the Python virtual environment and set up project dependencies in editable mode:

powershell -ExecutionPolicy Bypass -File scripts/bootstrap.ps1

Install pyteal setuptools compiler constraints:

.venv\Scripts\pip.exe install "setuptools==69.5.1"

2. Configure Environment

Copy the example environment file and adjust variables:

cp .env.example .env

Note: The default configurations are actively pointed to the live Algorand TestNet.

3. Build & Deploy Smart Contracts

Compile smart contracts to generate TEAL outputs and deploy them:

# Compile TEAL
.venv\Scripts\python.exe scripts/build_contracts.py

# Deploy to TestNet (Configure DEPLOYER_MNEMONIC in .env first)
.venv\Scripts\python.exe scripts/deploy_contracts.py

4. Run Locally

Launch the backend and frontend simultaneously:

# Terminal 1: Backend API
.venv\Scripts\uvicorn.exe apps.api.app.main:app --host 0.0.0.0 --port 8000 --reload

# Terminal 2: Frontend Dashboard
cd apps/web
npm run dev

๐ŸŽฎ Active Testnet Deployments & Demo

StakeNet is actively deployed on the Algorand TestNet for public audit:

Contract Application ID
Registry 768717553
Staking 768717557
Escrow 768717571
Audit 768717572
Reputation 768717577

Scenarios to Test (Judge Mode / Guided Demos)

Toggle to the Guided Demos tab on the dashboard to trigger live scenarios:

  • Scenario A: Successful hiring of a staked Translation provider.
  • Scenario B: Successful hiring of a staked Summarization provider.
  • Scenario C: Sequential pipeline (Translation โž” Summarization).
  • Scenario D (Self-Healing): Intentionally triggers a failure โž” Slashes provider collateral โž” Automatically discovers and invokes alternative.

๐Ÿ—บ๏ธ Roadmap

Phase 1: Core Framework (Completed)

  • On-chain Agent Registry & Staking Contracts
  • Escrow system with audit logging
  • Verification pipeline with 10 pluggable validators
  • Authoritative ranking mechanics

Phase 2: Cognitive Intelligence (Completed)

  • Natural language planner & vector semantic search
  • x402 pay-per-call micro-payments integration
  • Python SDK Client for standalone scripts
  • Glassmorphic dashboard with live SVG agent network visual graph

Phase 3: Scaling & Production (Future)

  • Cross-chain bridge escrow options (USDC/ALGO)
  • Decentralized validator network for verification proofs
  • Zero-knowledge output proof verification

๐ŸŒŒ Why StakeNet?

For AI agents to build a flourishing economy, they must transact with confidence. High-frequency API billing cannot rely on monthly human contracts. Traditional centralized marketplaces charge high commissions and centralize control.

StakeNet establishes decentralized skin-in-the-game. By backing claims with blockchain-enforced collateral, AI agents establish a trust protocol that runs as autonomously as the agents themselves.


๐Ÿค Contributors

  • Built for the BlockHack Hackathon by the StakeNet Core Team.
  • Special thanks to the Algorand Foundation and GoPlausible for payment facilitator APIs.

Built with โค๏ธ by developers who believe in an autonomous AI future.

About

The Economic Underwriting & Trust Layer for Autonomous AI Commerce

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages