Unit ID
z8xAeL7Ii4NSaJrMnUDV6OsN8HZ20O5hoD0UjB/xi0Q=
Received
03.06.2020 15:33:20
Confirmation delay (full node)
19 minutes 23 seconds
Confirmation delay (light node)
31 minutes 57 seconds
Messages
Definition
Definition: [ "autonomous agent", { "bounce_fees": { "base": 10000 }, "init": "{ $type = trigger.data.type; if(!exists($type)){ bounce("'type' required"); } $owner = params.owner; $asset = params.asset; $goal = params.goal; $days = params.days; $unit = params.unit; $start_timestamp = params.timestamp; $balance = var['balance'] OTHERWISE 0; }", "messages": { "cases": [ { "if": "{$type == 'addReward'}", "init": "{ if($owner != trigger.address){ bounce("you are not admin"); } $unit_data = unit[$unit].messages[[.app='data']].payload; $amount = trigger.data.amount; if(exists($unit_data['reward_' || $amount]) OR exists(var['reward_' || $amount])){ bounce('reward already exists'); } }", "messages": [ { "app": "state", "state": "{ var['reward_' || $amount] = 1; response['result'] = 'new_reward:' || $amount; }" } ] }, { "if": "{$type == 'buy'}", "init": "{ $amount = trigger.output[[asset=$asset]]; if(!exists($amount)){ if(exists(var['ZT2B6UYBAEHDU5M3EM2MSMVA5OC2AHAY']['a2s_' || $asset])) { $name = var['ZT2B6UYBAEHDU5M3EM2MSMVA5OC2AHAY']['a2s_' || $asset]; } else { $name = $asset; } bounce("Donations can only occur in " || $name); } $unit_data = unit[$unit].messages[[.app='data']].payload; $unit_reward = $unit_data['reward_' || $amount]; $local_reward = var['reward_' || $amount]; $finish_timestamp = (86400 * $days) + $start_timestamp; if(timestamp > $finish_timestamp){ bounce("project finished"); } }", "messages": [ { "app": "state", "state": "{ if(!exists($unit_reward) AND !exists($local_reward)){ response['result'] = 'gratuitous donation'; } else { response['result'] = 'reward_amount:' || $amount; } var['balance'] += $amount; var['amount_' || trigger.address] += $amount; }" } ] }, { "if": "{$type == 'withdraw'}", "init": "{ if($owner != trigger.address){ bounce("you are not admin"); } if($balance < $goal){ bounce("goal not reached"); } $withdrawn = var['withdrawn'] OTHERWISE 0; if($balance - $withdrawn <= 0){ bounce('not enough money'); } }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}", "amount": "{$balance - $withdrawn}" } ] } }, { "app": "state", "state": "{ var['withdrawn'] += $balance - $withdrawn; }" } ] }, { "if": "{$type == 'refund'}", "init": "{ $finish_timestamp = (86400 * $days) + $start_timestamp; if(timestamp < $finish_timestamp){ bounce("project didn't finish"); } if($balance >= $goal){ bounce("goal achieved"); } $peer_amount = var['amount_' || trigger.address]; if(!exists($peer_amount) AND $peer_amount > 0){ bounce("I do not have your money"); } }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}", "amount": "{$peer_amount}" } ] } }, { "app": "state", "state": "{ var['amount_' || trigger.address] = false; response['result'] = 'done'; }" } ] } ] } } ]
Technical information
Fees:
3,311 bytes
(353 headers, 2958 payload)
Level:1356063
Witnessed level:1356050
Main chain index:1350543
Latest included mc index:1350542
Status:stable/confirmed/final