InstaContract/contracts/v1/InstaAddress.sol
2019-01-24 03:53:35 +05:30

27 lines
695 B
Solidity

pragma solidity ^0.4.24;
contract AddressRegistry {
event AddressSet(string name, address addr);
mapping(bytes32 => address) registry;
constructor() public {
registry[keccak256(abi.encodePacked("admin"))] = msg.sender;
}
function getAddr(string name) public view returns(address) {
return registry[keccak256(abi.encodePacked(name))];
}
function setAddr(string 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);
}
}