EnergyAttestationResolver API
The resolver is the stateless validation layer called by EAS on every attestation and revocation. It decodes, validates, and delegates to the registry.
Resolver Hooks
These functions are called automatically by EAS — you do not call them directly. They are documented here for understanding the validation pipeline.
onAttest
onAttest(Attestation attestation, uint256 value) → boolCalled by EAS on every new attestation. Performs the following validation:
1. Revert if resolver is paused
2. Decode attestation data (8 fields)
3. Validate structure:
- readingCount > 0
- readingIntervalMinutes > 0
- readings.length == readingCount
- method is non-empty
4. Validate project:
- Project exists and is registered
5. Validate attester:
- Per-project OR watcher-wide authorization
6. Validate energy type:
- For generators: energyType must be registered
7. Compute derived values:
- toTimestamp = fromTimestamp + readingCount * interval * 60
- energyWh = sum(readings)
8. Validate timestamps:
- toTimestamp > fromTimestamp (no overflow)
9. Delegate to registry.recordAttestation()onRevoke
onRevoke(Attestation attestation, uint256 value) → boolCalled by EAS on revocation. Always allowed, even when the resolver is paused. Decodes the attestation data, computes energyWh and toTimestamp, and delegates to registry.recordRevocation().
Admin Functions
pause / unpause
pause()unpause()Pause or resume attestation processing. Pausing blocks new attestations but does not affect revocations. Contract owner only.
getRegistry
getRegistry() → addressReturns the address of the EnergyRegistry this resolver writes to.
isPayable
isPayable() → boolAlways returns false — energy attestations carry no ETH value.