Unit ID
56NIkVJ9gSDxrRq1BILUGjSZCKIZQdf4SzO+n0fC+ME=
Received
19.08.2019 12:36:38
Confirmation delay (full node)
2 minutes 40 seconds
Confirmation delay (light node)
5 minutes 4 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ // JAA, Joint Account Agent $owner = "O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; //office_testnet_wallet $account = trigger.data.account otherwise trigger.data.ac otherwise ""; // sha256()? $trigger = trigger.address; $pay_amount = trigger.data.amount otherwise trigger.data.am otherwise 0; $pay_address = trigger.data.address otherwise trigger.data.ad otherwise ""; $pay_id_received = trigger.data.pay_id otherwise trigger.data.pi otherwise ""; // use cases $setup = (trigger.data.a1) AND (trigger.data.a2); // minimum 2. $init_pay = ($pay_amount>0) AND ($pay_address !=""); $validate_pay = $pay_id_received != ""; $cancel = ($pay_id_received != "") AND (trigger.data.cancel==true); }", "messages": { "cases": [ { "if": "{$setup}", "init": "{ if ($account=="") bounce ("need account name"); if (var[$account]) bounce ("Account "||$account||" already exist!"); }", "messages": [ { "app": "state", "state": "{ var[$account] = trigger.output[[asset=base]]; var[$account||"_1"] = trigger.data.a1; var[$account||"_2"] = trigger.data.a2; response['message'] = 'Multi-sig account set for '||$account||'. '; }" } ] }, { "if": "{$init_pay}", "init": "{ if ($account=="") bounce ("need account name"); if (!var[$account]) bounce ("Account "||$account||" do not exist!"); $pay_id_created = sha256($account||'>'||$pay_address||': '||$pay_amount); $validator_num = ($trigger == var[$account||"_1"]) ? "2": "1"; $validator = $account||"_"||$validator_num; }", "messages": [ { "app": "data", "payload": { "message": "{"JAA: Your approval is required for a payment from the account '"||$account||" to pay "||$pay_amount||" to "||$pay_address||", please send me back the pay_id linked to validate the transaction. "}", "pay_id": "{$pay_id_created}" } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{var[$validator]}", "amount": 1000 } ] } }, { "app": "state", "state": "{ var[$pay_id_created||"_account"] = $account; var[$pay_id_created||"_amount"] = $pay_amount; var[$pay_id_created||"_address"] = $pay_address; var[$pay_id_created||"_initiator"] = trigger.address; var[$pay_id_created||"_v"||$validator_num||"_required"] = true; response['message'] = "Payment "||$pay_id_created||" created and approvals requested"; }" } ] }, { "if": "{$validate_pay}", "init": "{ $account_received = var[$pay_id_received||"_account"] otherwise ""; $amount = var[$pay_id_received||"_amount"] otherwise 0; $address = var[$pay_id_received||"_address"] otherwise ""; if ($account_received == "") bounce ("Payment ID "||$pay_id_received||" do not exist!"); $validator_num = ($trigger == var[$account_received||"_1"]) ? "1": "2"; $require = $pay_id_received||"_v"||$validator_num||"_required"; if (var[$require] != true) bounce ("Your validation is not required!"); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$address}", "amount": "{$amount}" } ] } }, { "app": "state", "state": "{ var[$account_received] = false; var[$address] = false; var[$amount] = false; var[$require] = false; response['message'] = "Payment of "||$amount||" done to "||$address||" from account "||$account; }" } ] }, { "if": "{$cancel}", "init": "{ $account_received = var[$pay_id_received||"_account"] otherwise ""; $amount = var[$pay_id_received||"_amount"] otherwise 0; $address = var[$pay_id_received||"_address"] otherwise ""; if (trigger.address == var[$account_received||"_1"]) $cancel_valid = true; if (trigger.address == var[$account_received||"_2"]) $cancel_valid = true; if (trigger.address == $address) $cancel_valid = true; if ($cancel_valid==false) bounce ("You must be a party to cancel!"); }", "messages": [ { "app": "state", "state": "{ var[$account_received] = false; var[$address] = false; var[$amount] = false; var[$require] = false; response['message'] = "Payment of "||$amount||" to "||$address||" is cancelled by "||trigger.address; }" } ] }, { "messages": [ { "init": "{ if ($account=="") bounce ("need account name"); $input = trigger.output[[asset=base]]; }", "app": "state", "state": "{ var[$account] += $input; response['message'] = $input||" added to the account "||$account; }" } ] } ] } } ]
Technical information
Fees:
4,605 bytes
(353 headers, 4252 payload)
Level:1009988
Witnessed level:1009981
Main chain index:1008806
Latest included mc index:1008805
Status:stable/confirmed/final