Documentation

EnergyRegistry API

Complete function reference for the EnergyRegistry contract — the permanent state layer of the protocol.

Watcher Management

registerWatcher

Solidity
registerWatcher(string name) → uint64 watcherId

Register a new watcher. The caller becomes the owner. Fully permissionless — no approval required. Emits WatcherRegistered.

transferWatcherOwnership

Solidity
transferWatcherOwnership(uint64 watcherId, address newOwner)

Transfer ownership of a watcher to a new address. Only the current watcher owner can call this. Emits WatcherOwnershipTransferred.

getWatcher

Solidity
getWatcher(uint64 watcherId) → Watcher

Returns the Watcher struct (owner, registered, name).

isWatcherRegistered

Solidity
isWatcherRegistered(uint64 watcherId) → bool

getNextWatcherId

Solidity
getNextWatcherId() → uint64

Returns the next watcher ID that will be assigned.

Project Management

registerProject

Solidity
registerProject(uint64 watcherId, string name, uint8 projectType) → uint64 projectId

Register a new project under a watcher. projectType: 0 = generator, 1 = consumer (immutable). Only the watcher owner can call this. Emits ProjectRegistered.

deregisterProject

Solidity
deregisterProject(uint64 projectId)

Deregister a project. Blocks new attestations but preserves all historical data and accumulators. Emits ProjectDeregistered.

transferProject

Solidity
transferProject(uint64 projectId, uint64 toWatcherId)

Transfer a project to another watcher. Migrates accumulated energy totals. Both the source watcher owner must call this. Emits ProjectTransferred.

getProject

Solidity
getProject(uint64 projectId) → Project

Returns the Project struct (watcherId, registered, projectType, name).

getWatcherProjects

Solidity
getWatcherProjects(uint64 watcherId) → uint64[]

Returns all project IDs under a watcher (including deregistered ones).

setProjectMetadataURI

Solidity
setProjectMetadataURI(uint64 projectId, string uri)

Set or update the metadata URI for a project. Watcher owner only. Emits ProjectMetadataURISet.

getProjectMetadataURI

Solidity
getProjectMetadataURI(uint64 projectId) → string

Attester Management

addAttester

Solidity
addAttester(uint64 projectId, address attester)

Whitelist an attester for a specific project. Watcher owner only. Emits AttesterAdded.

removeAttester

Solidity
removeAttester(uint64 projectId, address attester)

Remove an attester from a project. Emits AttesterRemoved.

addAttesters

Solidity
addAttesters(uint64 projectId, address[] attesters)

Batch whitelist multiple attesters for a project.

addWatcherAttester

Solidity
addWatcherAttester(uint64 watcherId, address attester)

Whitelist an attester for all projects under a watcher. Emits AttesterAdded with projectId=0.

removeWatcherAttester

Solidity
removeWatcherAttester(uint64 watcherId, address attester)

Energy Accumulators

getTotalGeneratedEnergy

Solidity
getTotalGeneratedEnergy(uint64 projectId) → uint256

Returns total generated energy in Wh for a project.

getTotalConsumedEnergy

Solidity
getTotalConsumedEnergy(uint64 projectId) → uint256

getTotalGeneratedEnergyByWatcher

Solidity
getTotalGeneratedEnergyByWatcher(uint64 watcherId) → uint256

getTotalConsumedEnergyByWatcher

Solidity
getTotalConsumedEnergyByWatcher(uint64 watcherId) → uint256

Period Lookup

getAttestedPeriodUID

Solidity
getAttestedPeriodUID(uint64 projectId, uint64 fromTimestamp, uint64 toTimestamp) → bytes32

Returns the UID of the attestation covering this period, or bytes32(0) if not attested or revoked.

Resolver Authorization

authorizeResolver

Solidity
authorizeResolver(address resolver)

Authorize a resolver to write to the registry. Contract owner only.

deauthorizeResolver

Solidity
deauthorizeResolver(address resolver)

isAuthorizedResolver

Solidity
isAuthorizedResolver(address resolver) → bool