-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWertherserverRegistry.sol
More file actions
36 lines (30 loc) · 1.23 KB
/
WertherserverRegistry.sol
File metadata and controls
36 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract WertherserverRegistry {
struct Service {
address owner;
string status;
string endpoint;
}
mapping(string => Service) public services;
event ServiceRegistered(string name, address owner, string endpoint);
event ServiceUpdated(string name, string status);
function registerService(string memory name, string memory endpoint) public {
require(services[name].owner == address(0), "Service already exists");
services[name] = Service({
owner: msg.sender,
status: "active",
endpoint: endpoint
});
emit ServiceRegistered(name, msg.sender, endpoint);
}
function updateServiceStatus(string memory name, string memory status) public {
require(services[name].owner == msg.sender, "Not the service owner");
services[name].status = status;
emit ServiceUpdated(name, status);
}
function getService(string memory name) public view returns (address owner, string memory status, string memory endpoint) {
Service memory service = services[name];
return (service.owner, service.status, service.endpoint);
}
}