InstaContract/contracts/InstaAddress.sol

23 lines
661 B
Solidity
Raw Permalink Normal View History

2019-02-22 17:00:57 +00:00
pragma solidity 0.5.0;
2018-10-25 12:59:05 +00:00
2019-01-27 17:50:14 +00:00
contract AddressRegistry {
event AddressSet(string name, address addr);
2018-10-29 11:19:01 +00:00
mapping(bytes32 => address) 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 memory 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 memory name, address addr) public {
require(msg.sender == getAddr("admin") || msg.sender == getAddr("owner"), "Permission Denied");
registry[keccak256(abi.encodePacked(name))] = addr;
emit AddressSet(name, addr);
}
}