Skip to content

Instantly share code, notes, and snippets.

@yakkomajuri
Created February 24, 2019 15:12
Show Gist options
  • Save yakkomajuri/4787ac67d6e81ae3520a05c6e03d84d1 to your computer and use it in GitHub Desktop.
Save yakkomajuri/4787ac67d6e81ae3520a05c6e03d84d1 to your computer and use it in GitHub Desktop.
pragma solidity^0.5.0;
contract CertificateReg {
struct Certificate {
string name;
string course;
string date;
string instructor;
}
event TellMeTheIndex (uint);
uint index;
mapping(uint => Certificate) certificates;
function registerCert(string memory name, string memory course, string memory date, string memory instructor) public {
certificates[index] = Certificate(name, course, date, instructor);
index++;
emit TellMeTheIndex(index - 1);
}
function viewCertificate(uint _index) public view returns (string memory, string memory, string memory, string memory) {
return (certificates[_index].name, certificates[_index].course, certificates[_index].date, certificates[_index].instructor);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment