Technical Reference — v1.0

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.

1. Device Layer

IoT devices (ESP32 + PZEM-004T, industrial Modbus/RS485 meters) measuring energy and signing data with Ed25519. Private key stored in Secure Element (ATECC608).

2. Provisioning Service

Registers and provisions devices. Delivers signed Device Manifest with configuration parameters (heartbeat interval, proof threshold, trust level).

3. Device Registry

Authoritative source of device state. Stores identity, ownership, lifecycle state, manifest version, capabilities, and audit metadata.

4. Policy Engine

Evaluates protocol rules. Determines device eligibility, applies protocol policies, and produces deterministic policy decisions.

5. Oracle Network

Performs cryptographic verification of Ed25519 signatures, validates nonces and timestamps, aggregates data into pools, and submits verified operations for execution.

6. Smart Contract (Solana)

Two programs: enrg-mvp (core protocol) and enrg-profile (energy profiles). Communicates via CPI using declare_program!. Executes immutable state transitions.

7. DAO Governance

Governs protocol evolution. Parameter updates, protocol upgrades, treasury management through decentralized voting.

Key Principle: The protocol is blockchain-independent. The Solana implementation is the first reference implementation. Each component is replaceable without architectural changes to unrelated components.

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
Program ID (devnet) 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.

Program ID (devnet) H9GDJQhaLqHeZZmuiqL1JTCaQ4nSquKterUyFVRdL5GZ

Instructions

InstructionProgramDescription
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()
StateDescriptionCan Mint?
UNREGISTEREDDevice unknown to the systemNo
REGISTEREDCryptographic identity created, not bound to ownerNo
CLAIMEDBound to owner, not yet configuredNo
PROVISIONEDConfigured, manifest received, time syncedNo
ACTIVEProducing and sending ProofsYes
QUARANTINEUnder suspicion, Proofs not mintedNo
MAINTENANCEService mode, no Proofs sentNo
REVOKEDPermanently removed from the protocolNo

Source: ADR-0005: Device States

Oracle Flow

  1. Device measures energy every 10 minutes using PZEM-004T or industrial Modbus/RS485 meter
  2. Device signs data packet {device_id, timestamp, energy_wh, nonce} with Ed25519 private key (stored in ATECC608 Secure Element)
  3. Device sends signed packet to Oracle API (POST /api/v1/proof/submit)
  4. Oracle verifies Ed25519 signature via solana_instructions_sysvar::get_instruction_relative
  5. Oracle validates monotonic nonce (replay protection) and timestamp (MAX_PROOF_AGE = 1 hour)
  6. Oracle checks device status in Device Registry (must be ACTIVE)
  7. Oracle aggregates verified readings into a pool. When pool reaches 1 MWh threshold, initiates minting
  8. Oracle calls mint_energy on enrg-mvp program with signed OracleReport
  9. Smart contract verifies oracle signature, validates producer PDA, calculates max_energy_wh = max_power_w * 10 / 60
  10. SRC tokens minted via CPI to SPL Token program: 85% to producer, 15% distributed to vault funds
  11. enrg-profile updated via CPI: record_production updates 30-day rolling energy window
OracleReport structure: {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.

Source programs/enrg-mvp/src/security/ed25519.rs

Replay Protection

  • Monotonic nonce — each device has an incrementing counter. Duplicate nonces are rejected.
  • Timestamp validationMAX_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

ThreatMitigation
SpoofingEd25519 cryptographic identity, ATECC608 Secure Element
TamperingSigned data packets, on-chain verification
RepudiationMonotonic nonce + timestamp audit trail
Information DisclosurePublic blockchain, no private data on-chain
Denial of ServiceGas limits, rate limiting, PDA architecture
Elevation of PrivilegePDA ownership checks, separation of concerns

Device Trust Levels

LevelEquipmentMining Limit
BasicESP32 + PZEM-004TUp to 100 kWh/month
VerifiedCertified household meterUp to 10 MWh/month
IndustrialSiemens, ABB, SchneiderUnlimited
InstitutionalEnergy company with auditUnlimited

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

MethodEndpointDescription
GET/statsProtocol-wide statistics (total_energy_mwh, active_producers, total_supply)
POST/device/registerRegister a new device ({device_id, public_key, wallet_address})
POST/proof/submitSubmit signed proof of production
GET/device/:id/statusGet device status and accumulated energy

Tokenomics

PropertyValue
TickerSRC (Source)
Max Supply1,000,000,000 SRC (fixed cap)
Decimals9
Peg1 SRC = 1 MWh verified energy
Protocol Fee15% (85% to producer)

Fee Distribution (15% of Every Mint)

  • 20% Buyback & Burn — constant deflationary pressure via buyback_and_burn instruction
  • 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 SourceMultiplier
Solar / Wind / Hydro100%
Biogas80%
Fossil50%

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