Unit ID
t7ivkNo7RDntMjZyyT4ThT6pQ0pb+bhuly7GBiVKZdk=
Received
21.09.2019 21:30:33
Confirmation delay (full node)
3 minutes 43 seconds
Confirmation delay (light node)
5 minutes 49 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $ASSET = 'hd936lRtPN11pkgNv8qVnqN2OHMyAp8P/NsLp6KsuqA='; $DEFAULT_FEE = 1000; $FEE_THRESHOLD = 10000; $LOW_FEE = -600;//-unit[trigger.unit].fee; $addr = trigger.address; $ATTESTOR_ADDR = 'JBGMJI7XSKLKNHZF26BUBWHVUZSDV3P5'; if(!attestation[[attestors=$ATTESTOR_ADDR, address=$addr,ifnone=false]]) bounce('Not allowed to use, please attest your address with '||$ATTESTOR_ADDR); $A = 'a'; $P = 'p'; $addr_key = $A||$addr; if(typeof(var['fee']) == 'number'){ $bal = balance[base] - trigger.output[[asset=base]]; if(var['fee'] > 0 AND $bal > $FEE_THRESHOLD) $change_fee = $LOW_FEE; if(var['fee'] < 0 AND $bal < 2000) $change_fee = $DEFAULT_FEE; if(var['fee'] < 0 and !$change_fee) $fee = $LOW_FEE; else $fee = $DEFAULT_FEE; } else{ $fee = $DEFAULT_FEE; $change_fee = $DEFAULT_FEE; } $base_inp = trigger.output[[asset=base]] - $fee; $value = trigger.data.value; if(!trigger.data.approve AND $value AND (typeof($value) != 'number' OR $value <= 0)) bounce('Value param invalid'); }", "messages": { "cases": [ { "if": "{ trigger.data.approve }", "init": "{ $approve = trigger.data.approve; $approve_key = $P || $addr || $approve; if(!is_valid_address($approve)) bounce('approve param invalid, specify address to approve instead of any other value'); if(!$value) bounce('Value param missing'); if(!var[$addr_key]) bounce('You have no funds'); if(typeof($value) != 'number' OR $value < 0) bounce('Value param invalid'); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$addr}", "amount": "{$base_inp}" } ] } }, { "app": "state", "state": "{ if($change_fee) var['fee'] = $change_fee; var[$approve_key] = $value; if(var[$approve_key] == 0) var[$approve_key] = false; response['message'] = 'Approved '||$approve||' to spend '||$value ||' from your account'; }" } ] }, { "if": "{ trigger.data.deposit }", "init": "{ if(trigger.output[[asset!=base]].asset != 'none') $asset = trigger.output[[asset!=base]].asset; else bounce('You must deposit '||$ASSET); if($asset == 'ambiguous') bounce('Only 1 asset per tx'); if($asset != $ASSET) bounce('You must deposit '||$ASSET); $asset_inp = trigger.output[[asset!=base]]; }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$addr}", "amount": "{$base_inp}" } ] } }, { "app": "state", "state": "{ if($change_fee) var['fee'] = $change_fee; var[$addr_key] += $asset_inp; response['message'] = 'Added '||$asset_inp||' to your account'; }" } ] }, { "if": "{ trigger.data.withdraw }", "init": "{ if(!var[$addr_key]) bounce('Nothing to withdraw'); $max_w = var[$addr_key]-(var[$addr_key] % 1); if(!$value) bounce('Value param missing, max to withdraw '||$max_w) ; $w_amount = $value - ($value % 1); if($w_amount <= 0) bounce('Max to withdraw '||$max_w); if($w_amount > $max_w) bounce('Not enough funds, max to withdraw '||$max_w); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$addr}", "amount": "{$base_inp}" } ] } }, { "app": "payment", "payload": { "asset": "{$ASSET}", "outputs": [ { "address": "{$addr}", "amount": "{$w_amount}" } ] } }, { "app": "state", "state": "{ if($change_fee) var['fee'] = $change_fee; var[$addr_key] -= $w_amount; response['message'] = 'Withdrawn '||$w_amount||' from your account'; }" } ] }, { "if": "{ trigger.data.transfer }", "init": "{ $transfer = trigger.data.transfer; if(!is_valid_address($transfer)) bounce('transfer param invalid, specify address to instead of any other value'); if(!var[$addr_key]) bounce('No funds found'); if(!$value) bounce('Value param missing'); if($value > var[$addr_key]) bounce('You have max '||var[$addr_key]); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$addr}", "amount": "{$base_inp}" } ] } }, { "app": "state", "state": "{ if($change_fee) var['fee'] = $change_fee; var[$A || $transfer] += $value; var[$addr_key] -= $value; if(var[$addr_key] == 0) var[$addr_key] = false; response['message'] = 'Transfered '||$value||' to '||$transfer; }" } ] }, { "if": "{ trigger.data.transfer_from }", "init": "{ $from = trigger.data.transfer_from; $to = trigger.data.to; $from_key = $A || $from; $perm_key = $P || $from || $addr; if(!is_valid_address($from)) bounce('transfer_from param invalid, specify from address instead of any other value'); if(!$to) bounce('To param missing'); if(!is_valid_address($to)) bounce('To param invalid'); if(!var[$from_key]) bounce('Account have no funds'); if(!$value) bounce('Value param missing'); if(!var[$perm_key]) bounce('Not allowed to spend'); if(var[$perm_key] < $value) bounce('You can spend max '||var[$perm_key]); if($value > var[$from_key]) bounce('Account have '||var[$from_key]); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$addr}", "amount": "{$base_inp}" } ] } }, { "app": "state", "state": "{ if($change_fee) var['fee'] = $change_fee; var[$A || $to] += $value; var[$from_key] -= $value; if(var[$from_key] == 0) var[$from_key] = false; var[$perm_key] -= $value; if(var[$perm_key] == 0) var[$perm_key] = false; response['message'] = 'Transfered '||$value||' to '||$to; }" } ] }, { "messages": [ { "app": "state", "state": "{ if(trigger.output[[asset!=base]].asset != 'none') bounce('To deposit an asset, use deposit param'); var['fee'] = $LOW_FEE; response['usage'] = 'Send param = 1 for continue. Accepted params: deposit,withdraw,transfer,transfer_from,approve'; response['message'] = 'Received bytes for funding AA operation, thaanks!'; }" } ] } ] } } ]
Technical information
Fees:
5,716 bytes
(353 headers, 5363 payload)
Level:1069832
Witnessed level:1069825
Main chain index:1068597
Latest included mc index:1068596
Status:stable/confirmed/final