Registering a Watcher
A watcher is your identity on EnergyAS. Once registered, you can create projects, whitelist attesters, and start submitting energy data.
1. Register Your Watcher
Registration is fully permissionless. Call registerWatcher with a human-readable name:
Terminal
npx hardhat run scripts/setup.ts --network <network>
# Choose: 1) Register a new watcher
# Enter your watcher name (e.g., "Solar Co")JavaScript
const tx = await registry.registerWatcher("Solar Co");
const receipt = await tx.wait();
// Extract watcherId from WatcherRegistered event2. Create a Project
Projects represent individual energy sites. Each project is either a generator or consumer — this cannot be changed after creation.
Terminal
npx hardhat run scripts/setup.ts --network <network>
# Choose: 2) Register a new project
# Enter watcher ID, project name, and type (0=generator, 1=consumer)JavaScript
const tx = await registry.registerProject(
watcherId, // your watcher ID
"Farm Alpha", // project name
0 // 0 = generator, 1 = consumer
);3. Whitelist Attesters
Before anyone can submit readings for a project, they must be whitelisted. You have two options:
JavaScript
await registry.addAttester(projectId, attesterAddress);JavaScript
await registry.addWatcherAttester(watcherId, attesterAddress);Note
Use per-project whitelisting for IoT devices. If one device is compromised, it can only affect a single project. Use watcher-wide access for manual backup operators who need to attest across all projects.
4. Set Project Metadata (Optional)
Add off-chain metadata to your project — location, certifications, dashboards:
JavaScript
await registry.setProjectMetadataURI(projectId, "ipfs://Qm...");Ongoing Management
- Add or remove attesters as devices change
- Deregister projects that are no longer active (historical data is preserved)
- Transfer projects to another watcher if ownership changes
- Transfer watcher ownership for key rotation or team changes