Documentation

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

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 (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

Solidity
onRevoke(Attestation attestation, uint256 value) → bool

Called 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

Solidity
pause()
Solidity
unpause()

Pause or resume attestation processing. Pausing blocks new attestations but does not affect revocations. 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.