Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.22;
- contract Example{
- struct Institution {
- bytes32 name;
- bool exists;
- }
- event AddedInstitution(bytes32 name);
- mapping(bytes32 => Institution) institutions;
- //add an institution
- function addInstitution(
- bytes32 name,
- bytes32 upi
- ) public {
- require(!isInstitutionExists(upi));
- institutions[upi].name = name;
- institutions[upi].exists = true;
- emit AddedInstitution(name);
- }
- //get an institution
- function getInstitution(bytes32 upi) public constant returns (bytes32 name){
- require(isInstitutionExists(upi));
- return (
- institutions[upi].name
- );
- }
- //is institution exist
- function isInstitutionExists(bytes32 upi) private constant returns (bool){
- if (institutions[upi].exists) {
- return true;
- }
- return false;
- }
- '0x4d6f6920556e7669766572736974790000000000000000000000000000000000'
- > web3.toAscii('0x4d6f6920556e7669766572736974790000000000000000000000000000000000')
- 'Moi Unviversity'
Add Comment
Please, Sign In to add comment