InstaContract/contracts/v1/InstaAddress.sol

22 lines
661 B
Solidity
Raw Normal View History

pragma solidity ^0.5.0;
2018-10-25 12:59:05 +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);
}
}