Created
February 24, 2019 15:12
-
-
Save yakkomajuri/4787ac67d6e81ae3520a05c6e03d84d1 to your computer and use it in GitHub Desktop.
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
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