Created
October 12, 2016 20:42
-
-
Save blackyblack/c89cc447986752202d0f183d0f6ac12c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* A contract to store a list of messages. Obtainable as events. */ | |
/* Deployment: | |
Owner: 0xeb5fa6cbf2aca03a0df228f2df67229e2d3bd01e | |
Last address: TBD | |
ABI: [{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_dataInfo","type":"string"},{"name":"_version","type":"uint256"},{"name":"_eventType","type":"uint16"},{"name":"_timeSpan","type":"uint256"}],"name":"add","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[],"name":"flush","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"contentCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"type":"constructor"},{"payable":false,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"dataInfo","type":"string"},{"indexed":true,"name":"version","type":"uint256"},{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"timePage","type":"uint256"},{"indexed":false,"name":"eventType","type":"uint16"},{"indexed":false,"name":"timeSpan","type":"uint256"},{"indexed":false,"name":"payment","type":"uint256"}],"name":"LogStore","type":"event"}] | |
Optimized: yes | |
Solidity version: v0.4.3-nightly.2016-10-11 | |
*/ | |
pragma solidity ^0.4.0; | |
contract Store { | |
//enum EventTypes | |
uint16 constant internal None = 0; | |
uint16 constant internal Add = 1; | |
uint16 constant internal Cancel = 2; | |
address private owner; | |
uint public contentCount = 0; | |
event LogStore(string dataInfo, uint indexed version, address indexed sender, uint indexed timePage, uint16 eventType, uint timeSpan, uint payment); | |
modifier onlyOwner { | |
if (msg.sender != owner) | |
throw; | |
_; | |
} | |
function Store() { owner = msg.sender; } | |
function kill() onlyOwner { suicide(owner); } | |
function flush() onlyOwner { | |
if(!owner.send(this.balance)) | |
throw; | |
} | |
function add(string _dataInfo, uint _version, uint16 _eventType, uint _timeSpan) payable { | |
if(_eventType != Add && _eventType != Cancel) throw; | |
//item listing | |
if(_eventType == Add) { | |
if(_timeSpan > 4 weeks) { | |
throw; | |
} | |
//4 weeks or less listing costs 0,01 ether | |
if(msg.value != (10 finney)) throw; | |
} else { | |
if(msg.value > 0) throw; | |
} | |
contentCount++; | |
LogStore(_dataInfo, _version, msg.sender, block.timestamp / (1 days), _eventType, _timeSpan, msg.value); | |
} | |
function () { | |
throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment