AONA Oracle Program

Decentralized water quality monitoring on Solana. Store sensor readings on-chain with autonomous agent verification.

⛓️ Solana Program⚓ Anchor Framework🔧 Devnet
Program Address
3SPZr1HBntkGvrTUCZnivEpCm4PsShHZ8nbxYeLUotwLDevnet

View on Solana Explorer: 3SPZr1HB...

Program Architecture

📦Accounts

Node Account

Represents a physical water monitoring sensor. Stores authority (owner), agent (authorized submitter), name, and PDA bump.

State Account

Stores the latest sensor reading with timestamp, pH, turbidity, conductivity, temperature, water level, and sequence number.

⚙️Instructions

create_node

Initialize a new monitoring node. Creates PDA using seeds: ["node", authority, agent].

submit_reading

Submit water quality data from authorized agent. Emits ReadingEvent and updates State PDA with new readings.

Water Quality Metrics

pH Level
ph: f32

Acidity/alkalinity measurement (0-14 scale)

Safe Range: 6.5 - 8.5

Turbidity
turbidity: f32

Water clarity measurement in NTU (Nephelometric Turbidity Units)

Safe Range: < 1.0 NTU

Conductivity
conductivity: f32

Electrical conductivity in µS/cm (dissolved solids indicator)

Safe Range: < 1500 µS/cm

Temperature
temp: f32

Water temperature in Celsius

Safe Range: < 30°C

Water Level
level: f32

Water level measurement in meters

Safe Range: Varies

Timestamp
ts: i64

Unix timestamp of reading submission

Safe Range: Current time

How It Works

1

Node Registration

Authority (sensor owner) calls create_node with agent public key and node name. Program creates Node PDA to track ownership and authorization.

2

Agent Authorization

Only the designated agent (autonomous AI or sensor firmware) can submit readings. Agent must sign submit_reading transactions.

3

Reading Submission

Authorized agent submits ReadingInput struct with water quality metrics. Program validates agent signature against Node account.

4

State Update

Program creates or updates State PDA with new readings, increments sequence number, and emits ReadingEvent for indexers.

5

Data Access

Frontend queries Node and State accounts via RPC. AI agents analyze readings and generate alerts. x402 protocol enables micropayment for data access.

Security Features

Access Control
  • Only authorized agent can submit readings for a node
  • Agent signature verified on every submit_reading call
  • PDAs prevent unauthorized account modifications
  • Authority retains ownership and control over node
Error Handling
6000: UnauthorizedAgent

Thrown when a non-authorized agent attempts to submit readings. Prevents data tampering.

Quick Start

1. Seed Nodes (Development)

npm run seed

Creates demo water monitoring nodes on Solana devnet with sample readings.

2. Run Autonomous Agent

npm run agent

Launches AI agent that discovers nodes, pays for data access via x402, and analyzes water quality.

3. View Dashboard

npm run dev

Start Next.js frontend to visualize on-chain data, agent alerts, and network metrics.