Created
September 14, 2016 11:48
-
-
Save blackyblack/26b61b794b08d4afa10af87d10022472 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: 0x12239738fd728d4a77efe9167a852b0e51eec6eb | |
ABI: [{"constant":false,"inputs":[{"name":"datainfo","type":"string"},{"name":"version","type":"uint256"},{"name":"datatype","type":"uint256"},{"name":"timespan","type":"uint256"}],"name":"add","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"flush","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"contentCount","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"inputs":[],"type":"constructor"},{"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":"datatype","type":"uint256"},{"indexed":false,"name":"timespan","type":"uint256"},{"indexed":false,"name":"payment","type":"uint256"}],"name":"content","type":"event"}] | |
Optimized: yes | |
Solidity version: v0.3.6-2016-08-16-970260b | |
*/ | |
contract store { | |
address owner; | |
uint public contentCount = 0; | |
event content(string datainfo, uint indexed version, address indexed sender, uint indexed timepage, uint datatype, uint timespan, uint payment); | |
modifier onlyowner { if (msg.sender == owner) _ } | |
function store() public { owner = msg.sender; } | |
///TODO: remove in release | |
function kill() onlyowner { suicide(owner); } | |
function flush() onlyowner { | |
owner.send(this.balance); | |
} | |
function add(string datainfo, uint version, uint datatype, uint timespan) { | |
//item listing | |
if(datatype == 1) { | |
//2 weeks listing costs 0,04 USD = 0,004 ether | |
if(timespan <= 1209600) { | |
if(msg.value < (4 finney)) return; | |
//4 weeks listing costs 0,06 USD = 0,006 ether | |
} else if(timespan <= 2419200) { | |
if(msg.value < (6 finney)) return; | |
//limit 4 weeks max | |
} else { | |
timespan = 2419200; | |
if(msg.value < (6 finney)) return; | |
} | |
} | |
//revert higher payment transactions | |
if(msg.value > (6 finney)) throw; | |
contentCount++; | |
content(datainfo, version, msg.sender, block.timestamp / 86400, datatype, timespan, msg.value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment