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 metadataURIField Reference
| Field | Type | Description |
|---|---|---|
| projectId | uint64 | ID of the registered energy project |
| readingCount | uint32 | Number of interval readings (must equal readings.length) |
| readingIntervalMinutes | uint32 | Duration of each interval in minutes |
| readings | uint256[] | Per-interval energy in Wh (array length must match readingCount) |
| fromTimestamp | uint64 | Start of the reporting period (Unix seconds) |
| method | string | Collection method: "manual", "iot", "estimated", etc. |
| energyType | uint8 | Energy source type ID (generators only; 0 for consumers) |
| metadataURI | string | Optional 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.
| Unit | Wh Value | Example |
|---|---|---|
| 1 Wh | 1 | Single LED bulb for one hour |
| 1 kWh | 1,000 | Typical household hourly consumption |
| 1 MWh | 1,000,000 | Small commercial facility daily |
| 1 GWh | 1,000,000,000 | Utility-scale solar farm monthly |
Period Locking
The registry enforces two uniqueness constraints per project:
| Constraint | Key | Purpose |
|---|---|---|
| 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.