Created
February 19, 2017 10:58
-
-
Save jacohend/b8c5c5d3bd1afcea3285a69651ce73d9 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.4.0; | |
contract EthNotary { | |
struct Document{ | |
string creator; | |
string sender; | |
string document; | |
uint created; | |
uint blocknumber; | |
} | |
mapping(string => Document) documents; | |
uint length; | |
function EthNotary(){ | |
length = 0; | |
} | |
function toString(address x) returns (string) { | |
bytes memory b = new bytes(20); | |
for (uint i = 0; i < 20; i++) | |
b[i] = byte(uint8(uint(x) / (2**(8*(19 - i))))); | |
return string(b); | |
} | |
function add(string title, string cr, string doc){ | |
documents[title] = Document(cr, toString(msg.sender), doc, block.timestamp, block.number); | |
length++; | |
} | |
function get(string title) constant returns (string creator, string sender, string document, uint time, uint createdno, uint nowno){ | |
creator= documents[title].creator; | |
sender=documents[title].sender; | |
document= documents[title].document; | |
time= documents[title].created; | |
createdno= documents[title].blocknumber; | |
nowno= block.number; | |
} | |
function getDoc(string title) constant returns (string document){ | |
document= documents[title].document; | |
} | |
function getTimestamp(string title) constant returns (uint created){ | |
created= documents[title].created; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment