Skip to content

Instantly share code, notes, and snippets.

Last active May 26, 2018
What would you like to do?
pragma solidity ^0.4.19;
contract Account{
/* struct account{
string pubKey;
string priKey;
} */
struct account_user{
string pubKey;
string userHash;
struct user{
string userHash;
string metadataHash;
string userClass;
bool isOrg;
mapping (string => string) userHashtoPubkey;
mapping (string => user) userHashToUser;
//you can add a modifier to it to prevent other users to add/link accounts.
function createAccount(string pubKey, string userHash, string metadataHash, string userClass, bool isOrg) public {
//adding to account
//linking the pubKey to a userHash.
userHashtoPubkey[userHash] = pubKey;
userHashToUser[userHash] = user(userHash, metadataHash, userClass, isOrg);
function getAccount(string userHash) public view returns(string metadataHash, string userClass, bool isOrg){
return (userHashToUser[userHash].metadataHash, userHashToUser[userHash].userClass, userHashToUser[userHash].isOrg);
//figure out the account change flow.
function changeAccount(string newUserHash, string pubKey) public {
userHashtoPubkey[newUserHash] = pubKey;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment