Skip to content

Instantly share code, notes, and snippets.

@fiatjaf fiatjaf/groupon.ethereum
Last active Aug 29, 2015

Embed
What would you like to do?
if (tx.value < 100 * block.basefee) {
return
}
if (tx.data[0] == 'BUY') {
// buy deal
payment = tx.value - 100 * block.basefee
shareholders = contract.storage['sh']
deal = contract.storage[tx.data[1]]
if (payment >= deal.price*1.02) {
mktx(deal.owner, payment - deal.price, 0, 0)
piece = deal.price * 0.02 / sh.length
shareholders.forEach(function (s) {
mktx(s, piece, 0, 0)
})
deal.buyers.push([tx.sender, block.timestamp])
contract.storage[tx.data[1]] = deal
}
}
else if (tx.data[0] == 'OFFER') {
// offer deal
if (contract.storage[tx.sender].rating < tx.data[2] * 0.9) {
contract.storage[tx.data[1]] = {
price: tx.data[2],
owner: tx.sender,
buyers: []
}
}
}
else if (tx.data[0] == 'RATE') {
// rate deal/customer
}
else if (tx.data[0] == 'INVEST') {
// invest in the business
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.