Technical Overview
Deep-dive into the ENRG Protocol architecture, on-chain programs, device lifecycle, oracle flow, security model, and API reference.
Architecture
The ENRG Protocol consists of seven independent components, each with a clearly defined responsibility. This separation ensures cryptographic trust, implementation independence, and long-term protocol stability.
IoT devices (ESP32 + PZEM-004T, industrial Modbus/RS485 meters) measuring energy and signing data with Ed25519. Private key stored in Secure Element (ATECC608).
Registers and provisions devices. Delivers signed Device Manifest with configuration parameters (heartbeat interval, proof threshold, trust level).
Authoritative source of device state. Stores identity, ownership, lifecycle state, manifest version, capabilities, and audit metadata.
Evaluates protocol rules. Determines device eligibility, applies protocol policies, and produces deterministic policy decisions.
Performs cryptographic verification of Ed25519 signatures, validates nonces and timestamps, aggregates data into pools, and submits verified operations for execution.
Two programs: enrg-mvp (core protocol) and enrg-profile (energy profiles). Communicates via CPI using declare_program!. Executes immutable state transitions.
Governs protocol evolution. Parameter updates, protocol upgrades, treasury management through decentralized voting.
On-Chain Programs
enrg-mvp — Core Protocol
Core program responsible for:
- Verifying oracle Ed25519 signatures via
solana_instructions_sysvar::get_instruction_relative - Minting SRC tokens via CPI to SPL Token program
- Managing the Energy Vault (buyback, staking, DAO, emergency funds)
- Device lifecycle management (8 states per ADR-0005)
- Enforcing mint constraints (max supply, nonce, timestamp, power limits)
- Staking, unstaking, and reward distribution
- Founder vesting and buyback & burn
EsaKY8C3EZeRLL1wG5UECAnDWjbLfWJr7jL3pBLmpFfW
enrg-profile — Energy Profile
Manages energy producer profiles:
- Participant profiles (PDA per wallet)
- Device registration and metadata
- 30-day rolling energy window (
update_energy_window_u128) - Rated power configuration (determines max energy per mint)
enrg-mvp calls enrg_profile::cpi::record_production during each mint
via declare_program! to update the producer's energy profile.
The profile's rated_power determines the maximum energy per mint.
H9GDJQhaLqHeZZmuiqL1JTCaQ4nSquKterUyFVRdL5GZ
Instructions
| Instruction | Program | Description |
|---|---|---|
initialize_profile |
enrg-profile | Initialize participant profile PDA |
update_metadata |
enrg-profile | Update profile metadata (name, country, rated power) |
record_production |
enrg-profile | Record energy production in 30-day rolling window (called via CPI from enrg-mvp) |
read_profile |
enrg-profile | Read energy profile data |
mint_energy |
enrg-mvp | Verify oracle signature + mint SRC tokens. 85% to producer, 15% fee distributed to vault funds |
create_producer |
enrg-mvp | Register a new energy producer |
stake / unstake |
enrg-mvp | Stake and withdraw SRC tokens |
claim_rewards |
enrg-mvp | Claim staking rewards |
buyback_and_burn |
enrg-mvp | Burn tokens from the buyback fund |
register_device |
enrg-mvp | Register device in lifecycle (UNREGISTERED → REGISTERED) |
claim_device |
enrg-mvp | Claim device ownership (REGISTERED → CLAIMED) |
provision_device |
enrg-mvp | Provision device (CLAIMED → PROVISIONED) |
activate_device |
enrg-mvp | Activate device (PROVISIONED → ACTIVE) |
quarantine_device |
enrg-mvp | Quarantine device (ACTIVE → QUARANTINE) |
release_from_quarantine |
enrg-mvp | Release from quarantine (QUARANTINE → ACTIVE) |
revoke_device |
enrg-mvp | Revoke device (ACTIVE → REVOKED) |
Account Structure
EnergyProducer PDA (enrg-mvp)
seeds: ["producer", authority_pubkey]
{
authority: Pubkey, // device owner
device_id: String (32), // unique identifier
nonce: u64, // replay attack protection
energy_wh: u64, // total accumulated energy
timestamp: i64, // last confirmation time
max_power_w: u64, // nameplate power
signature: [u8; 64], // last signature
state: DeviceState, // 8-state lifecycle
is_initialized: bool,
}
EnergyProfile PDA (enrg-profile)
seeds: ["profile", authority_pubkey]
{
authority: Pubkey,
rated_power: u64, // W
device_model: String (32),
manufacturer: String (32),
country: String (32),
energy_window: [u128; 30], // 30-day rolling window
window_index: u8,
total_energy: u128,
is_initialized: bool,
}
Vault PDA (enrg-mvp)
seeds: ["vault"]
{
mint: Pubkey, // SRC token mint
authority: Pubkey, // deployer
is_initialized: bool,
}
Fund PDAs (enrg-mvp)
seeds: ["buyback" | "staking" | "dao" | "emergency", vault_pubkey]
{
vault: Pubkey,
total_deposits: u64,
is_initialized: bool,
}
Device Lifecycle (ADR-0005)
Every device in the ENRG Protocol follows a cryptographically enforced state machine with 8 states. Each state has clearly defined behavior, and transitions are only possible through authorized instructions.
UNREGISTERED
│
▼
REGISTERED ← register_device()
│
▼
CLAIMED ← claim_device()
│
▼
PROVISIONED ← provision_device()
│
▼
ACTIVE ← activate_device()
│
├── (suspicion) → QUARANTINE ← quarantine_device()
│ │
│ └── → ACTIVE ← release_from_quarantine()
│
├── (maintenance) → MAINTENANCE
│
└── (removal) → REVOKED ← revoke_device()
| State | Description | Can Mint? |
|---|---|---|
| UNREGISTERED | Device unknown to the system | No |
| REGISTERED | Cryptographic identity created, not bound to owner | No |
| CLAIMED | Bound to owner, not yet configured | No |
| PROVISIONED | Configured, manifest received, time synced | No |
| ACTIVE | Producing and sending Proofs | Yes |
| QUARANTINE | Under suspicion, Proofs not minted | No |
| MAINTENANCE | Service mode, no Proofs sent | No |
| REVOKED | Permanently removed from the protocol | No |
Source: ADR-0005: Device States
Oracle Flow
- Device measures energy every 10 minutes using PZEM-004T or industrial Modbus/RS485 meter
- Device signs data packet
{device_id, timestamp, energy_wh, nonce}with Ed25519 private key (stored in ATECC608 Secure Element) - Device sends signed packet to Oracle API (
POST /api/v1/proof/submit) - Oracle verifies Ed25519 signature via
solana_instructions_sysvar::get_instruction_relative - Oracle validates monotonic nonce (replay protection) and timestamp (MAX_PROOF_AGE = 1 hour)
- Oracle checks device status in Device Registry (must be ACTIVE)
- Oracle aggregates verified readings into a pool. When pool reaches 1 MWh threshold, initiates minting
- Oracle calls
mint_energyon enrg-mvp program with signed OracleReport - Smart contract verifies oracle signature, validates producer PDA, calculates
max_energy_wh = max_power_w * 10 / 60 - SRC tokens minted via CPI to SPL Token program: 85% to producer, 15% distributed to vault funds
- enrg-profile updated via CPI:
record_productionupdates 30-day rolling energy window
{device_id: [u8; 32], timestamp: i64, energy_wh: u64, nonce: u64, signature: [u8; 64]}
Security
Ed25519 Verification
All device and oracle signatures are verified on-chain via
solana_instructions_sysvar::get_instruction_relative.
This reads the serialized Ed25519 instruction from the transaction's
instruction sysvar and verifies the public key, message, and signature
without trusting any off-chain component.
programs/enrg-mvp/src/security/ed25519.rs
Replay Protection
- Monotonic nonce — each device has an incrementing counter. Duplicate nonces are rejected.
- Timestamp validation —
MAX_PROOF_AGE = 1 hour. Proofs older than 1 hour are rejected. - Rate limiting — Oracle API: 200 req/min general, 100 req/min proof submission, 20 req/min device registration.
STRIDE Threat Model
| Threat | Mitigation |
|---|---|
| Spoofing | Ed25519 cryptographic identity, ATECC608 Secure Element |
| Tampering | Signed data packets, on-chain verification |
| Repudiation | Monotonic nonce + timestamp audit trail |
| Information Disclosure | Public blockchain, no private data on-chain |
| Denial of Service | Gas limits, rate limiting, PDA architecture |
| Elevation of Privilege | PDA ownership checks, separation of concerns |
Device Trust Levels
| Level | Equipment | Mining Limit |
|---|---|---|
| Basic | ESP32 + PZEM-004T | Up to 100 kWh/month |
| Verified | Certified household meter | Up to 10 MWh/month |
| Industrial | Siemens, ABB, Schneider | Unlimited |
| Institutional | Energy company with audit | Unlimited |
Energy Reputation Score (ERS)
Each producer accumulates a reputation score based on:
- Duration of flawless operation
- Volume of verified energy
- Absence of anomalies in the generation profile
High ERS provides advantages in pool reward distribution and access to premium ENRG Market features. Sudden spikes, night-time generation, and profile anomalies trigger automatic quarantine.
Oracle API
Base URL: https://enrg-oracle.onrender.com/api/v1
| Method | Endpoint | Description |
|---|---|---|
| GET | /stats | Protocol-wide statistics (total_energy_mwh, active_producers, total_supply) |
| POST | /device/register | Register a new device ({device_id, public_key, wallet_address}) |
| POST | /proof/submit | Submit signed proof of production |
| GET | /device/:id/status | Get device status and accumulated energy |
Tokenomics
| Property | Value |
|---|---|
| Ticker | SRC (Source) |
| Max Supply | 1,000,000,000 SRC (fixed cap) |
| Decimals | 9 |
| Peg | 1 SRC = 1 MWh verified energy |
| Protocol Fee | 15% (85% to producer) |
Fee Distribution (15% of Every Mint)
- 20% Buyback & Burn — constant deflationary pressure via
buyback_and_burninstruction - 40% Staking Rewards — distributed to SRC stakers proportionally to their share
- 30% DAO Reserve — governed by token holder voting
- 10% Emergency Fund — protocol insurance for unforeseen events
Source Multipliers
| Energy Source | Multiplier |
|---|---|
| Solar / Wind / Hydro | 100% |
| Biogas | 80% |
| Fossil | 50% |
Mint Energy Formula
max_energy_wh = producer.max_power_w * 10 / 60
total_mint = energy_wh * 10^9 // convert to base units with 9 decimals
producer_share = total_mint * 85 / 100
fee = total_mint * 15 / 100
// Fee distribution:
buyback = fee * 20 / 100
staking = fee * 40 / 100
dao = fee * 30 / 100
emergency = fee * 10 / 100