Skip to content

Instantly share code, notes, and snippets.

@Aniket-Engg
Created June 2, 2018 06:18
Show Gist options
  • Save Aniket-Engg/ff88e1b199ee2f5bcac88e59525e0261 to your computer and use it in GitHub Desktop.
Save Aniket-Engg/ff88e1b199ee2f5bcac88e59525e0261 to your computer and use it in GitHub Desktop.
Standard Ethereum Claims Registry
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