Skip to content

Instantly share code, notes, and snippets.

@fiatjaf
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiatjaf/11098342 to your computer and use it in GitHub Desktop.
Save fiatjaf/11098342 to your computer and use it in GitHub Desktop.
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