Unit ID
53zyjheeRXOdWiBj7dfZNtdBt7itwJ6lxsgQsa7pfOY=
Received
21.09.2019 16:33:09
Confirmation delay (full node)
3 minutes 6 seconds
Confirmation delay (light node)
5 minutes 23 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ if(trigger.output[[asset=base]] < 6000) bounce('Not enough funds for fees'); $def_fee = trigger.data.default_fee and trigger.data.default_fee > 0 ? round(trigger.data.default_fee) : 1000; $fee_thr = trigger.data.fee_thresold and trigger.data.fee_thresold >= 3000 ? round(trigger.data.fee_thresold) : 10000; $low_fee = trigger.data.low_fee and trigger.data.low_fee < 0 ? round(trigger.data.low_fee) : -600; $attestor = trigger.data.attestor and is_valid_address(trigger.data.attestor) ? trigger.data.attestor : false; $field = trigger.data.attestor and typeof(trigger.data.field) == 'string' ? trigger.data.field : false; if(trigger.output[[asset!=base]].asset != 'none') $asset = trigger.output[[asset!=base]].asset; else bounce('You must send an asset'); if($asset == 'ambiguous') bounce('Only 1 asset per tx'); }", "messages": { "cases": [ { "messages": [ { "app": "payment", "payload": { "asset": "{$asset}", "outputs": [ { "address": "{trigger.address}", "amount": "{trigger.output[[asset!=base]]}" } ] } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}" } ] } }, { "app": "definition", "payload": { "definition": [ "autonomous agent", { "{'init'}": "{ "{$ASSET = '"||$asset||"';" || "$DEFAULT_FEE = "||$def_fee||";" || "$FEE_THRESHOLD = "||$fee_thr||";" || "$LOW_FEE = "||$low_fee||";" || ($attestor?("$ATTESTOR_ADDR = '"||$attestor||"';if(!attestation[[attestors=$ATTESTOR_ADDR, address=trigger.address,ifnone=false]]"||($field?("['"||$field||"']"):"")||") bounce('Not allowed to use, please attest your address with '||$ATTESTOR_ADDR);"):"") || "if(trigger.data.to AND !is_valid_address(trigger.data.to)) bounce('To param invalid');" || "if(trigger.data.from AND !is_valid_address(trigger.data.from)) bounce('From param invalid');" || "if(trigger.data.spender AND !is_valid_address(trigger.data.spender)) bounce('Spender param invalid');" || "if(!trigger.data.approve AND trigger.data.value AND (typeof(trigger.data.value) != 'number' OR trigger.data.value <= 0)) bounce('Value param invalid');" || "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;}" }", "messages": { "{'cases'}": [ { "{'if'}": "{ "{trigger.data.approve}" }", "{'init'}": "{ "{if(!trigger.data.spender) bounce('Spender param missing');" || "if(!trigger.data.value) bounce('Value param missing');" || "if(!var['a_' || trigger.address]) bounce('You have no funds');" || "if(typeof(trigger.data.value) != 'number' OR trigger.data.value < 0) bounce('Value param invalid');}" }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{"{trigger.address}"}", "amount": "{"{$base_inp}"}" } ] } }, { "app": "state", "{'state'}": "{ "{if($change_fee) var['fee'] = $change_fee;" || "var['perm_' || trigger.address || '_' || trigger.data.spender] = trigger.data.value;" || "if(var['perm_' || trigger.address || '_' || trigger.data.spender] == 0) var['perm_' || trigger.address || '_' || trigger.data.spender] = false;" || "response['message'] = 'Approved '||trigger.data.spender||' to spend '||trigger.data.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": "{"{trigger.address}"}", "amount": "{"{$base_inp}"}" } ] } }, { "app": "state", "{'state'}": "{ "{if($change_fee) var['fee'] = $change_fee;" || "var['a_' || trigger.address] += $asset_inp;" || "response['message'] = 'Added '||$asset_inp||' to your account';}" }" } ] }, { "{'if'}": "{ "{trigger.data.withdraw}" }", "{'init'}": "{ "{if(!var['a_' || trigger.address]) bounce('Nothing to withdraw');" || "$max_w = var['a_' || trigger.address]-(var['a_' || trigger.address] % 1);" || "if(!trigger.data.value) bounce('Value param missing, max to withdraw '||$max_w);" || "$w_amount = trigger.data.value - (trigger.data.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": "{"{trigger.address}"}", "amount": "{"{$base_inp}"}" } ] } }, { "app": "payment", "payload": { "asset": "{"{$ASSET}"}", "outputs": [ { "address": "{"{trigger.address}"}", "amount": "{"{$w_amount}"}" } ] } }, { "app": "state", "{'state'}": "{ "{if($change_fee) var['fee'] = $change_fee;" || "var['a_' || trigger.address] -= $w_amount;" || "response['message'] = 'Withdrawn '||$w_amount||' from your account';}" }" } ] }, { "{'if'}": "{ "{trigger.data.transfer}" }", "{'init'}": "{ "{if(!var['a_'||trigger.address]) bounce('No funds found');" || "if(!trigger.data.to) bounce('To param missing');" || "if(!trigger.data.value) bounce('Value param missing');" || "if(trigger.data.value > var['a_'||trigger.address]) bounce('You have max '||var['a_'||trigger.address]);}" }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{"{trigger.address}"}", "amount": "{"{$base_inp}"}" } ] } }, { "app": "state", "{'state'}": "{ "{if($change_fee) var['fee'] = $change_fee;" || "var['a_' || trigger.data.to] += trigger.data.value;" || "var['a_'||trigger.address] -= trigger.data.value;" || "if(var['a_'||trigger.address] == 0) var['a_'||trigger.address] = false;" || "response['message'] = 'Transfered '||trigger.data.value||' to '||trigger.data.to;}" }" } ] }, { "{'if'}": "{ "{trigger.data.transfer_from}" }", "{'init'}": "{ "{if(!trigger.data.from) bounce('From param missing');" || "if(!var['a_' || trigger.data.from]) bounce('Account have no funds');" || "if(!trigger.data.to) bounce('To param missing');" || "if(!trigger.data.value) bounce('Value param missing');" || "if(!var['perm_' || trigger.data.from || '_' || trigger.address]) bounce('Not allowed to spend');" || "if(var['perm_' || trigger.data.from || '_' || trigger.address] < trigger.data.value) bounce('You can spend max '||var['perm_' || trigger.data.from || '_' || trigger.address]);" || "if(trigger.data.value > var['a_' || trigger.data.from]) bounce('Account have '||var['a_' || trigger.data.from]);}" }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{"{trigger.address}"}", "amount": "{"{$base_inp}"}" } ] } }, { "app": "state", "{'state'}": "{ "{if($change_fee) var['fee'] = $change_fee;" || "var['a_' || trigger.data.to] += trigger.data.value;" || "var['a_' || trigger.data.from] -= trigger.data.value;" || "if(var['a_' || trigger.data.from] == 0) var['a_' || trigger.data.from] = false;" || "var['perm_' || trigger.data.from || '_' || trigger.address] -= trigger.data.value;" || "if(var['perm_' || trigger.data.from || '_' || trigger.address] == 0) var['perm_' || trigger.data.from || '_' || trigger.address] = false;" || "response['message'] = 'Transfered '||trigger.data.value||' to '||trigger.data.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!';}" }" } ] } ] } } ] } }, { "app": "state", "state": "{ response['message']='AA for '||$asset||'created'; if($attestor){ if($field){ response['security'] = $attestor||' will have to give permission and will be able to block accounts'; } else{ response['security'] = $attestor||' will have to give permission but will not be able to block accounts, specify an attestation field with field param'; } } else{ response['security'] = 'Free access, nobody will be able to block anyone. Use attestor param if you want to restrict AA to certain addresses'; } }" } ] } ] } } ]
Technical information
Fees:
8,397 bytes
(353 headers, 8044 payload)
Level:1069477
Witnessed level:1069469
Main chain index:1068242
Latest included mc index:1068241
Status:stable/confirmed/final