From 08fe2453dea33077a183d3b7031c1e1c400643f1 Mon Sep 17 00:00:00 2001 From: Robert Martin-Legene <robert@nic.ar> Date: Mon, 23 Jul 2018 17:28:54 -0300 Subject: [PATCH] Adding a simpler TSA --- .../abi | 1 + network5445/contracts/TimeStampAuthority | 1 + src/contract.TimeStampAuthority.sol | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 network5445/contracts/0x0fa811ac6643a29ad9c17acbed34918a4875f63c/abi create mode 120000 network5445/contracts/TimeStampAuthority create mode 100644 src/contract.TimeStampAuthority.sol diff --git a/network5445/contracts/0x0fa811ac6643a29ad9c17acbed34918a4875f63c/abi b/network5445/contracts/0x0fa811ac6643a29ad9c17acbed34918a4875f63c/abi new file mode 100644 index 0000000..c03a9f4 --- /dev/null +++ b/network5445/contracts/0x0fa811ac6643a29ad9c17acbed34918a4875f63c/abi @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"hash","type":"bytes32"}],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"hash","type":"bytes32"}],"name":"put","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/network5445/contracts/TimeStampAuthority b/network5445/contracts/TimeStampAuthority new file mode 120000 index 0000000..9e920f6 --- /dev/null +++ b/network5445/contracts/TimeStampAuthority @@ -0,0 +1 @@ +0x0fa811ac6643a29ad9c17acbed34918a4875f63c \ No newline at end of file diff --git a/src/contract.TimeStampAuthority.sol b/src/contract.TimeStampAuthority.sol new file mode 100644 index 0000000..8b4c4e6 --- /dev/null +++ b/src/contract.TimeStampAuthority.sol @@ -0,0 +1,21 @@ +// 20180718 Robert Martin-Legene <robert@nic.ar> +// Time stamp authority + +pragma solidity ^0.4.24; + +contract TimeStampAuthority { + // This mapping is almost an "associative array" + mapping (bytes32 => uint) private hashes; + + // Stores the hash of the document in the mapping + function put( bytes32 hash ) public { + require( hashes[hash] == 0, "That checksum has already been stored." ); + hashes[hash] = block.number; + } + + // Returns the block number in which the hash was first seen + function get( bytes32 hash ) public view returns (uint) { + require( hashes[hash] != 0, "That checksum has never been stored." ); + return hashes[hash]; + } +} -- GitLab