Skip to content

Autonomous Oracles for Networked Aquatic Systems - Real-world water protection network powered by DePIN, IoT sensors, AI Agents and x402 micropayments - V 1.0 - x402 <> Solana Hackathon

Notifications You must be signed in to change notification settings

ValenteCreativo/AONA

Repository files navigation

AONA

Autonomous Oracles for Networked Aquatic systems — Real water protection through decentralized infrastructure and AI-powered analysis on Solana.

🌊 Mission

Transform water quality monitoring from reactive crisis management to proactive protection:

  • 🌐 DePIN Foundation — Community-owned sensors + smartphone reports
  • 🤖 Autonomous AI Agents — Self-executing intelligence with real Solana payments
  • 💰 x402 Micropayments — HTTP 402 Payment Required for sustainable data economy
  • 💳 Instant Payouts — Node operators receive earnings via Phantom CASH (ApplePay/GooglePay/VISA)
  • 📊 Oracle Integration — Switchboard price feeds for transparent USD pricing
  • 🔗 Real-Time Intelligence — USGS + Open-Meteo + blockchain synthesis

Solana x402 Switchboard AgentPay Phantom License


Explore Key Pages

Page Purpose
/dashboard Network overview + real-time agent activity
/atlas Interactive map (Open-Meteo + USGS + AONA nodes)
/nodes Sensor network with reputation rankings
/alerts AI-generated water quality alerts (EPA standards)
/contribute Submit smartphone sensor reports → earn Phantom CASH
/idl Solana program documentation

⚡ Quick Start (5 Minutes)

1. Clone & Install

git clone https://github.com/ValenteCreativo/AONA.git
cd AONA
npm install

2. Seed Blockchain (Optional — Uses Demo Fallback)

npm run seed
# Creates 10 water monitoring nodes on Solana devnet

3. Run Autonomous Agent

npm run agent
# Watch real x402 payments in action!
# Agent discovers nodes → pays SOL → fetches data → analyzes → generates alerts

4. Start Dashboard

npm run dev
# Open http://localhost:3000

🏗️ Architecture

┌──────────────────────┐
│  Physical Sensors    │ IoT devices + smartphone apps
│  pH, turbidity, temp │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│  Solana Blockchain   │ Anchor Program: 3SPZr1HBn...
│  Node Registry       │ Reputation-based pricing
│  State Accounts      │ Latest readings
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│  x402 Payment API    │ HTTP 402 Protocol
│  GET /nodes          │ FREE — discover network
│  GET /reading/[id]   │ PAID — requires SOL payment
│  Verify on-chain tx  │ Before serving data
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│  AI Water Analyst    │ Autonomous Agent
│  1. Discover nodes   │
│  2. Send SOL payment │ Real Solana transactions
│  3. Fetch data       │ + USGS + Open-Meteo enrichment
│  4. EPA analysis     │ Water quality standards
│  5. Generate alerts  │ Critical/Warning/Info
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│  Next.js Dashboard   │
│  Real-time atlas     │ Leaflet maps
│  Impact metrics      │ Protection stats
│  Alert management    │ AI warnings
│  Contribution portal │ Earn Phantom CASH
└──────────────────────┘

Program Address: 3SPZr1HBntkGvrTUCZnivEpCm4PsShHZ8nbxYeLUotwL Network: Solana Devnet View on Explorer


🔧 Tech Stack

Built with sponsor technologies driving the Solana ecosystem forward:

Blockchain & Payments

  • Solana — Sub-second finality, $0.00025 per transaction
    • @solana/web3.js v1.98.4
    • @coral-xyz/anchor v0.32.1 (Anchor framework)
  • x402 Protocol — HTTP 402 Payment Required
    • @coinbase/x402 v0.7.1
    • Autonomous agent payments with on-chain verification
  • Switchboard Oracle — SOL/USDC price feeds
    • @switchboard-xyz/solana.js v3.2.5
    • Real-time pricing for micropayments
  • Phantom CASH — Instant fiat conversion
    • ApplePay, GooglePay, VISA integration
    • DePIN-to-fiat bridge for contributors

Frontend

  • Next.js 15.1.6 — App router + React Server Components
  • Tailwind CSS v4.1.9 — Minimalist aqua-shodō aesthetic
  • Leaflet + react-leaflet — Interactive maps
  • shadcn/ui — Radix UI components

External APIs (Free, No Auth)

  • USGS Water Services — Government watershed data (13,500+ sites)
  • Open-Meteo — Global weather forecasts

🤖 Autonomous Agent

Location: agents/water-analyst/agent.js

Fully autonomous program demonstrating trustless agent architecture with real Solana payments:

Workflow

npm run agent
  1. Wallet Setup — Generate ephemeral keypair + airdrop SOL
  2. Node Discovery — Fetch sensor network from blockchain
  3. Payment Execution — Send SOL to node operators via x402
  4. Data Purchase — Retrieve readings with on-chain verification
  5. EPA Analysis — Check water quality against federal standards
  6. Alert Generation — Create actionable contamination warnings
  7. JSON Output — Save results to public/agent-output.json

Example Output

🤖 AONA Water Analyst Agent starting...
✅ Generated wallet: 76nEUPUPV2H7V5Gt2yL64TKNr2f83wSyexixwAu91wUc
💰 Balance: 1.0 SOL

🔍 Discovering nodes...
✅ Found 3 nodes on-chain

💧 Consulting: Colorado River — Grand County
  💸 Sending payment: 0.001 SOL...
  ✅ Payment sent: 2tC5MYYf6NPKLNqH...
  📡 Fetching data...
  ✅ Reading received
     pH: 6.2 ⚠️ CRITICAL (below 6.5)

============================================================
📊 AGENT EXECUTION SUMMARY
============================================================
Nodes Consulted: 3
Total Spent: 0.003 SOL
Alerts Generated: 5 (2 Critical, 2 Warning, 1 Info)
Overall Water Quality: FAIR
============================================================

💧 x402 API Endpoints

GET /api/x402/nodesFREE

Discover all water monitoring nodes with reputation rankings.

Response:

{
  "nodes": [{
    "id": "node-001-colorado",
    "name": "Colorado River — Grand County",
    "authority": "AuthorityPubkey...",
    "reputation": {
      "score": 92,
      "rank": "Platinum",
      "totalReadings": 1547,
      "uptime": 98.5
    },
    "price": { "sol": 0.001, "usd": 0.02 }
  }],
  "count": 3,
  "programId": "3SPZr1HBntkGvrTUCZnivEpCm4PsShHZ8nbxYeLUotwL"
}

GET /api/x402/reading/[nodeId]REQUIRES PAYMENT

Without Payment → HTTP 402:

{
  "error": "Payment required",
  "price": { "sol": 0.001, "usd": 0.02 },
  "recipient": "AuthorityPubkey..."
}

With Payment (header: X-Payment-Signature) → Data:

{
  "reading": { "ph": 7.2, "turbidity": 1.8, "temperature": 18.5 },
  "enrichment": {
    "usgs": { "siteName": "Colorado River at Glenwood Springs" },
    "weather": { "temperature": 22.5, "precipitation": 0 }
  },
  "payment": { "verified": true, "amount": { "sol": 0.001 } }
}

📊 Solana Program

Program ID: 3SPZr1HBntkGvrTUCZnivEpCm4PsShHZ8nbxYeLUotwL Framework: Anchor 0.32.1

Key Accounts

  • Node Account (PDA) — Seeds: ["node", authority, agent]
    • Stores operator address (payment recipient), authorized agent, metadata
  • State Account (PDA) — Seeds: ["state", node]
    • Latest readings: pH, turbidity, conductivity, temp, level, sequence

Instructions

  • create_node(name) — Initialize new sensor
  • submit_reading(data) — Submit water quality data (agent-only)

Security

  • Agent authorization via signature verification
  • PDA validation prevents unauthorized modifications
  • Custom error: UnauthorizedAgent (6000)

Full Documentation: Visit /idl page or run npm run idl


🌍 Water Quality Standards

Agent analyzes readings against EPA Safe Drinking Water Act standards:

Parameter Safe Warning Critical Unit
pH 6.5-8.5 Outside range <6.0 or >9.0
Turbidity <0.5 0.5-1.0 >1.0 NTU
Temperature <25 25-30 >30 °C
Conductivity <1000 1000-1500 >1500 μS/cm

Alert Levels: 🔴 Critical (immediate action) | 🟠 Warning (monitor) | 🟡 Info (awareness)


💳 DePIN Expansion — Smartphone Sensors

Anyone can contribute water quality reports using their smartphone:

  1. Visit /contribute page
  2. Enable Geolocation — Auto-detect your location
  3. Report Conditions — Describe water appearance, odor, debris
  4. AI Verification — Agent cross-references with USGS + Open-Meteo
  5. Earn Rewards — Verified reports receive SOL micropayments to Phantom CASH
  6. Convert to Fiat — Instant ApplePay/GooglePay/VISA conversion

Making water stewardship economically sustainable for everyday contributors worldwide.


📄 License

MIT License — See LICENSE


🙏 Acknowledgments

Built with technologies advancing the Solana ecosystem:

  • Solana Foundation — High-performance blockchain infrastructure
  • Coinbase — x402 Protocol specification and SDK
  • Switchboard — Decentralized oracle framework
  • Phantom — CASH integration for seamless DePIN-to-fiat conversion
  • USGS — Free public water quality data
  • Open-Meteo — Free global weather forecasts

🔗 Links


🌊 Water knows. The network translates. AONA. 🌊

From México with 💙

About

Autonomous Oracles for Networked Aquatic Systems - Real-world water protection network powered by DePIN, IoT sensors, AI Agents and x402 micropayments - V 1.0 - x402 <> Solana Hackathon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •