InstaContract/contracts/MoatAddress.sol

27 lines
702 B
Solidity
Raw Normal View History

pragma solidity ^0.4.24;
2018-10-25 12:59:05 +00:00
contract AddressRegistry {
event AddressSet(string name, address addr);
2018-10-27 12:07:21 +00:00
mapping(bytes32 => address) public registry;
2018-10-27 11:11:57 +00:00
constructor() public {
registry[keccak256(abi.encodePacked("admin"))] = msg.sender;
2018-10-27 11:11:57 +00:00
}
function getAddr(string name) public view returns(address) {
return registry[keccak256(abi.encodePacked(name))];
2018-10-27 11:11:57 +00:00
}
2018-10-25 18:44:53 +00:00
function setAddr(string name, address addr) public {
2018-10-28 17:36:35 +00:00
require(
msg.sender == getAddr("admin") ||
msg.sender == getAddr("owner"),
2018-10-28 17:36:35 +00:00
"Permission Denied"
);
registry[keccak256(abi.encodePacked(name))] = addr;
emit AddressSet(name, addr);
}
2018-10-28 16:59:07 +00:00
}