Documentation

Attestation Schema

Every energy attestation follows a single schema registered on the EAS SchemaRegistry. The schema defines the data structure that all attestations must conform to.

Schema Definition

uint64 projectId, uint32 readingCount, uint32 readingIntervalMinutes, uint256[] readings, uint64 fromTimestamp, string method, uint8 energyType, string metadataURI

Field Reference

FieldTypeDescription
projectIduint64ID of the registered energy project
readingCountuint32Number of interval readings (must equal readings.length)
readingIntervalMinutesuint32Duration of each interval in minutes
readingsuint256[]Per-interval energy in Wh (array length must match readingCount)
fromTimestampuint64Start of the reporting period (Unix seconds)
methodstringCollection method: "manual", "iot", "estimated", etc.
energyTypeuint8Energy source type ID (generators only; 0 for consumers)
metadataURIstringOptional URI to supporting evidence (IPFS or HTTPS)

Derived Values

The resolver computes two values from the attestation data. These are not stored in the attestation itself but are used by the registry:

Solidity
toTimestamp = fromTimestamp + readingCount * readingIntervalMinutes * 60
energyWh   = sum(readings)

ABI Encoding

Attestation data is ABI-encoded before submission to EAS:

JavaScript
import { AbiCoder } from 'ethers';

const data = AbiCoder.defaultAbiCoder().encode(
  [
    "uint64",    // projectId
    "uint32",    // readingCount
    "uint32",    // readingIntervalMinutes
    "uint256[]", // readings
    "uint64",    // fromTimestamp
    "string",    // method
    "uint8",     // energyType
    "string"     // metadataURI
  ],
  [
    1,                           // projectId
    3,                           // 3 readings
    60,                          // 60-minute intervals
    [100000, 150000, 200000],    // readings in Wh
    1700000000,                  // fromTimestamp
    "iot",                       // method
    1,                           // energyType (solar_pv)
    ""                           // metadataURI (optional)
  ]
);

Energy Units

Note

All energy values are in watt-hours (Wh), not kWh or MWh. This avoids floating-point precision issues on-chain.

UnitWh ValueExample
1 Wh1Single LED bulb for one hour
1 kWh1,000Typical household hourly consumption
1 MWh1,000,000Small commercial facility daily
1 GWh1,000,000,000Utility-scale solar farm monthly

Period Locking

The registry enforces two uniqueness constraints per project:

ConstraintKeyPurpose
Period uniqueness(projectId, fromTimestamp, toTimestamp)Prevents the same time window from being attested twice
Start-time uniqueness(projectId, fromTimestamp)Prevents two attestations with the same start, even with different durations

To correct an attestation, revoke it first (which clears the period lock), then re-attest with the corrected data.