EnergyAttestationResolver API
The resolver is the stateless validation layer called by EAS on every attestation and revocation attempt. 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 (7 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. Compute derived values:
- toTimestamp = fromTimestamp + readingCount * interval * 60
- energyWh = sum(readings)
7. Validate timestamps:
- toTimestamp > fromTimestamp (no overflow)
8. Route to registry:
- If refUID is zero: registry.recordAttestation()
- If refUID is set: validate replacement, then registry.recordReplacement()onAttest — Replacement Path
When refUID is set (non-zero), the resolver handles a replacement attestation:
1. Validate that the replacement targets the same project
2. Validate that the replacement covers the same time period
3. Delegate to registry.recordReplacement() with both old and new energy valuesThe registry adjusts accumulators by the delta and tracks the replacement chain.
onRevoke
onRevoke(Attestation attestation, uint256 value) → boolAlways reverts with DirectRevocationBlocked(). Direct revocations are not supported — corrections must go through the replacement mechanism via refUID to preserve a complete audit trail.
Admin Functions
pause / unpause
pause()unpause()Pause or resume attestation processing. Pausing blocks new attestations and replacements. 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.
renounceOwnership
Disabled — always reverts. This prevents accidental ownership lockout.