Created
June 2, 2018 06:18
-
-
Save Aniket-Engg/ff88e1b199ee2f5bcac88e59525e0261 to your computer and use it in GitHub Desktop.
Standard Ethereum Claims Registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract EthereumClaimsRegistry { | |
mapping(address => mapping(address => mapping(bytes32 => bytes32))) public registry; | |
event ClaimSet( | |
address indexed issuer, | |
address indexed subject, | |
bytes32 indexed key, | |
bytes32 value, | |
uint updatedAt); | |
event ClaimRemoved( | |
address indexed issuer, | |
address indexed subject, | |
bytes32 indexed key, | |
uint removedAt); | |
// create or update clams | |
function setClaim(address subject, bytes32 key, bytes32 value) public { | |
registry[msg.sender][subject][key] = value; | |
emit ClaimSet(msg.sender, subject, key, value, now); | |
} | |
function setSelfClaim(bytes32 key, bytes32 value) public { | |
setClaim(msg.sender, key, value); | |
} | |
function getClaim(address issuer, address subject, bytes32 key) public view returns(bytes32) { | |
return registry[issuer][subject][key]; | |
} | |
function removeClaim(address issuer, address subject, bytes32 key) public { | |
require(msg.sender == issuer); | |
delete registry[issuer][subject][key]; | |
emit ClaimRemoved(msg.sender, subject, key, now); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment