Skip to content

Instantly share code, notes, and snippets.

@alaahd
Created October 15, 2018 09:34
Show Gist options
  • Save alaahd/b4cdb956fb0546b4a4cf08a5c3e3f4a3 to your computer and use it in GitHub Desktop.
Save alaahd/b4cdb956fb0546b4a4cf08a5c3e3f4a3 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.24;
contract registry{
struct Certificate {
mapping(address => bool) attested;
mapping(address => string) ipfsRootHash;
}
mapping(string => Certificate) certificates;
function attest(string _hash, string _ipfsRootHash) public {
Certificate storage currentCertificate = certificates[_hash];
currentCertificate.attested[msg.sender] = true;
currentCertificate.ipfsRootHash[msg.sender] = _ipfsRootHash;
}
function verify(string _hash) public view returns (bool) {
return certificates[_hash].attested[msg.sender];
}
function getMetaData(string _hash) public view returns (string) {
require(certificates[_hash].attested[msg.sender]);
return certificates[_hash].ipfsRootHash[msg.sender];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment