Skip to content

Instantly share code, notes, and snippets.

@zabirauf
Created January 16, 2018 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zabirauf/bf011d3163ddd41d5b71dab70bdb21b0 to your computer and use it in GitHub Desktop.
Save zabirauf/bf011d3163ddd41d5b71dab70bdb21b0 to your computer and use it in GitHub Desktop.
// Code for PersonsAge.sol
pragma solidity ^0.4.15;
import { StringToUintMap } from "../libraries/StringToUintMap.sol";
contract PersonsAge {
StringToUintMap.Data private _stringToUintMapData;
event PersonAdded(string name, uint8 age);
event GetPersonAgeResponse(string name, uint8 age);
function addPersonAge(string name, uint8 age) public {
StringToUintMap.insert(_stringToUintMapData, name, age);
PersonAdded(name, age);
}
function getPersonAge(string name) public returns (uint8) {
uint8 age = StringToUintMap.get(_stringToUintMapData, name);
GetPersonAgeResponse(name, age);
return age;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment