Documentation

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

Note

These functions are called automatically by EAS — you do not call them directly. They are documented here for understanding the validation pipeline.

onAttest

Solidity
onAttest(Attestation attestation, uint256 value) → bool

Called 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 values

The registry adjusts accumulators by the delta and tracks the replacement chain.

onRevoke

Solidity
onRevoke(Attestation attestation, uint256 value) → bool

Always 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

Solidity
pause()
Solidity
unpause()

Pause or resume attestation processing. Pausing blocks new attestations and replacements. Contract owner only.

getRegistry

Solidity
getRegistry() → address

Returns the address of the EnergyRegistry this resolver writes to.

isPayable

Solidity
isPayable() → bool

Always returns false — energy attestations carry no ETH value.

renounceOwnership

Disabled — always reverts. This prevents accidental ownership lockout.