EnergyRegistry API
Complete function reference for the EnergyRegistry contract — the permanent state layer of the protocol.
Watcher Management
registerWatcher
registerWatcher(string name) → uint64 watcherIdRegister a new watcher. The caller becomes the owner. Fully permissionless — no approval required. Emits WatcherRegistered.
transferWatcherOwnership
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
getWatcher(uint64 watcherId) → WatcherReturns the Watcher struct (owner, registered, name).
isWatcherRegistered
isWatcherRegistered(uint64 watcherId) → boolgetNextWatcherId
getNextWatcherId() → uint64Returns the next watcher ID that will be assigned.
Project Management
registerProject
registerProject(uint64 watcherId, string name, uint8 projectType) → uint64 projectIdRegister a new project under a watcher. projectType: 0 = generator, 1 = consumer (immutable). Only the watcher owner can call this. Emits ProjectRegistered.
deregisterProject
deregisterProject(uint64 projectId)Deregister a project. Blocks new attestations but preserves all historical data and accumulators. Emits ProjectDeregistered.
transferProject
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
getProject(uint64 projectId) → ProjectReturns the Project struct (watcherId, registered, projectType, name).
getWatcherProjects
getWatcherProjects(uint64 watcherId) → uint64[]Returns all project IDs under a watcher (including deregistered ones).
setProjectMetadataURI
setProjectMetadataURI(uint64 projectId, string uri)Set or update the metadata URI for a project. Watcher owner only. Emits ProjectMetadataURISet.
getProjectMetadataURI
getProjectMetadataURI(uint64 projectId) → stringAttester Management
addAttester
addAttester(uint64 projectId, address attester)Whitelist an attester for a specific project. Watcher owner only. Emits AttesterAdded.
removeAttester
removeAttester(uint64 projectId, address attester)Remove an attester from a project. Emits AttesterRemoved.
addAttesters
addAttesters(uint64 projectId, address[] attesters)Batch whitelist multiple attesters for a project.
addWatcherAttester
addWatcherAttester(uint64 watcherId, address attester)Whitelist an attester for all projects under a watcher. Emits AttesterAdded with projectId=0.
removeWatcherAttester
removeWatcherAttester(uint64 watcherId, address attester)Energy Accumulators
getTotalGeneratedEnergy
getTotalGeneratedEnergy(uint64 projectId) → uint256Returns total generated energy in Wh for a project.
getTotalConsumedEnergy
getTotalConsumedEnergy(uint64 projectId) → uint256getTotalGeneratedEnergyByWatcher
getTotalGeneratedEnergyByWatcher(uint64 watcherId) → uint256getTotalConsumedEnergyByWatcher
getTotalConsumedEnergyByWatcher(uint64 watcherId) → uint256Period Lookup
getAttestedPeriodUID
getAttestedPeriodUID(uint64 projectId, uint64 fromTimestamp, uint64 toTimestamp) → bytes32Returns the UID of the attestation covering this period, or bytes32(0) if not attested or revoked.
Resolver Authorization
authorizeResolver
authorizeResolver(address resolver)Authorize a resolver to write to the registry. Contract owner only.
deauthorizeResolver
deauthorizeResolver(address resolver)isAuthorizedResolver
isAuthorizedResolver(address resolver) → bool