Unit ID
4a2VTBsJz94OLG5kio/+jzzPgO5p76y0AiwUnuN/KTc=
Received
29.08.2020 12:20:36
Confirmation delay (full node)
2 minutes 27 seconds
Confirmation delay (light node)
5 minutes 48 seconds
Messages
Definition
Definition: [ "autonomous agent", { "getters": "{ $polloAddr = => '5TT7JV3M5PNE2WSAA3YGOX7ZZXKIMG35'; $stableAsset = => 'blao'; }", "init": "{ $act= => trigger.data.action otherwise 'b'; $timespan = 60*60*24*30; $year = 24*60*60*365; if(trigger.output[[asset!=base]].asset != 'none'){ $asset = trigger.output[[asset!=base]].asset; if($asset and $asset != $stableAsset()) bounce('only bytes or stable asset'); } else $asset = 'base'; }", "messages": { "cases": [ { "if": "{ $act() == 'create' and $polloAddr() == trigger.address }", "messages": [ { "app": "state", "state": "{ var[trigger.unit||'_producer'] = trigger.data.producer; var[trigger.unit||'_amount_r'] = trigger.data.amount; if(trigger.data.stable) var[trigger.unit||'_asset'] = $stableAsset(); else var[trigger.unit||'_asset'] = 'base'; response['action'] = $act(); response['id'] = trigger.unit; response['producer'] = trigger.data.producer; response['amount'] = trigger.data.amount; }" } ] }, { "if": "{ $act() == 'cancel' and $polloAddr() == trigger.address }", "init": "{ if(!var[trigger.data.id||'_producer']) bounce('application not found'); if(var[trigger.data.id||'_donor']) bounce('already filled'); }", "messages": [ { "app": "state", "state": "{ var[trigger.data.id||'_producer'] = false; var[trigger.data.id||'_amount_r'] = false; var[trigger.data.id||'_asset'] = false; response['action'] = $act(); response['id'] = trigger.data.id; }" } ] }, { "if": "{ $act() == 'withdraw' and $polloAddr() == trigger.address }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}", "amount": "{balance[base] - storage_size - var['user_bytes'] - 10000}" } ] } }, { "app": "state", "state": "{ response['action'] = $act(); }" } ] }, { "if": "{ $act() == 'return' and trigger.address == $polloAddr() }", "init": "{ if(!var[trigger.data.id||'_producer']) bounce('application not found'); if(!var[trigger.data.id||'_donor']) bounce('not filled'); if(var[trigger.data.id||'_time']+$timespan < timestamp) bounce('donor must wait 30 days before return'); if(var[trigger.data.id||'_time']+$year > timestamp OR var[trigger.data.id||'_donor'] == $polloAddr()) $to_aa = true; }", "messages": [ { "if": "{!$to_aa}", "app": "payment", "payload": { "asset": "{var[trigger.data.id||'_asset']}", "outputs": [ { "address": "{trigger.data.addr}", "amount": "{var[trigger.data.id||'_amount']}" } ] } }, { "app": "state", "state": "{ if(!$to_aa){ if(var[trigger.data.id||'_asset'] == 'base'){ var['user_bytes'] -= var[trigger.data.id||'_amount']; } } else{ if(var[trigger.data.id||'_asset'] == 'base'){ var['donation_'||var[trigger.data.id||'_donor']] -= var[trigger.data.id||'_amount']; var['donation_'||$polloAddr()] += var[trigger.data.id||'_amount']; } else{ var['donationsc_'||var[trigger.data.id||'_donor']] -= var[trigger.data.id||'_amount']; var['donationsc_'||$polloAddr()] += var[trigger.data.id||'_amount']; } } var[trigger.data.id||'_amount'] = false; var[trigger.data.id||'_producer'] = false; var[trigger.data.id||'_donor'] = false; var[trigger.data.id||'_time'] = false; var[trigger.data.id||'_asset'] = false; response['action'] = $act(); response['id'] = trigger.data.id; if(trigger.data.addr) response['addr'] = trigger.data.addr; }" } ] }, { "if": "{ $act() == 'donate' and $polloAddr() == trigger.address }", "init": "{ if(!var[trigger.data.id||'_amount_r']){ bounce('application already filled'); } $donor = trigger.data.donor; if(!$donor) bounce('donor missing'); if(var[trigger.data.id||'_asset'] == 'base' and !var['donation_'||$donor]) bounce('donor dont have funds to donate'); if(var[trigger.data.id||'_asset'] != 'base' and !var['donationsc_'||$donor]) bounce('donor dont have funds to donate'); if(var[trigger.data.id||'_asset'] == 'base'){ if(var[trigger.data.id||'_amount_r'] > var['donation_'||$donor]) bounce('not enough funds, please refill'); } else{ if(var[trigger.data.id||'_amount_r'] > var['donationsc_'||$donor]) bounce('not enough funds, please refill'); } }", "messages": [ { "app": "state", "state": "{ if(var[trigger.data.id||'_asset'] == 'base'){ var['donation_'||$donor] -= var[trigger.data.id||'_amount_r']; } else{ var['donationsc_'||$donor] -= var[trigger.data.id||'_amount_r']; } var[trigger.data.id||'_amount'] = var[trigger.data.id||'_amount_r']; var[trigger.data.id||'_amount_r'] = false; var[trigger.data.id||'_donor'] = $donor; var[trigger.data.id||'_time'] = timestamp; response['action'] = $act(); response['id'] = trigger.data.id; response['donor'] = trigger.data.donor; }" } ] }, { "if": "{ $act() == 'confirm' and $polloAddr() == trigger.address }", "init": "{ if(!var[trigger.data.id||'_producer']) bounce('application not found'); if(var[trigger.data.id||'_amount_r']) bounce('not filled yet'); }", "messages": [ { "app": "payment", "payload": { "asset": "{var[trigger.data.id||'_asset']}", "outputs": [ { "address": "{var[trigger.data.id||'_producer']}", "amount": "{var[trigger.data.id||'_amount']}" } ] } }, { "app": "state", "state": "{ if(var[trigger.data.id||'_asset'] == 'base') var['user_bytes'] -= var[trigger.data.id||'_amount']; var[trigger.data.id||'_asset'] = false; var[trigger.data.id||'_amount'] = false; var[trigger.data.id||'_amount_r'] = false; var[trigger.data.id||'_producer'] = false; var[trigger.data.id||'_time'] = false; response['action'] = $act(); response['id'] = trigger.data.id; }" } ] }, { "init": "{ $donor = trigger.data.donor OTHERWISE $polloAddr(); }", "messages": [ { "if": "{$asset != 'base'}", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}", "amount": "{8000}" } ] } }, { "app": "state", "state": "{ if($asset == 'base'){ var['donation_'||$donor] += trigger.output[[asset=base]]; var['user_bytes'] += trigger.output[[asset=base]]; } else{ var['donationsc_'||$donor] += trigger.output[[asset!=base]]; } response['action'] = 'deposit'; response['asset'] = $asset; response['donor'] = $donor; }" } ] } ] } } ]
Technical information
Fees:
9,576 bytes
(452 headers, 9124 payload)
Level:1586272
Witnessed level:1586265
Main chain index:1579032
Latest included mc index:1579031
Status:stable/confirmed/final