Unit ID
RIDG/J19ePKi5Zf2UspJ9TRvYYEQff4aWLUJvPfdqUo=
Received
23.09.2019 20:11:11
Confirmation delay (full node)
2 minutes 50 seconds
Confirmation delay (light node)
4 minutes 54 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ // FOREVER CONSTANTE $AA_OWNER = "O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; // to collect the dust $AA_NAME = "THAANKS"; $LOPAVAA = "YICOQCAWUSFBIQGBB4HUPQ23U37RA5WG"; // AA used to get last or popular version of other non-sensitives AA $LIST_HOLDER_AA = var[$LOPAVAA]["HOLLAA_last_version"]; // get last version of HOLLAA $INSTRUCTIONS = "Every operation need 'account_name= <account name>', if you received a token just use it, 'token = <received token> optionaly with 'cancel = true' to deny the payment, to initiate a payment, define 'pay_to' and 'amount'. To create a new account, add users with 'add_user = <address>' mutiple times then 'activate_account = true' and chose 'hierarchical/flat = true'"; // get state and input $account_name = trigger.data.account_name otherwise bounce ($INSTRUCTIONS); }", "messages": { "cases": [ { "if": "{ trigger.data.add_user }", "init": "{ if (!!var[$account_name||"_owner"]) if (trigger.address != var[$account_name||"_owner"]) bounce ("Account "||$account_name||" already exist!"); if (!is_valid_address(trigger.data.add_user)) bounce ("Invalid address in 'add_user'!"); }", "messages": [ { "app": "data", "payload": { "list_name": "{ $account_name||"_users" }", "add": "{ trigger.data.add_user }", "value": "{ trigger.data.nick_name }" } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $LIST_HOLDER_AA }", "amount": 100 } ] } }, { "app": "state", "state": "{ var[$account_name||"_owner"] = trigger.address; var[$account_name||"_balance"] += trigger.output[[asset=base]].amount - 1000; response['message'] = 'One user added ^^'; }" } ] }, { "if": "{ trigger.data.activate_account }", "init": "{ if (!!var[$account_name||"_owner"]) if (trigger.address != var[$account_name||"_owner"]) bounce ($account_name||" already active!"); if (!trigger.data.hierachical and !trigger.data.flat) bounce ("you must specify 'hierarchical = true' or 'flat = true'"); }", "messages": [ { "app": "state", "state": "{ var[$account_name] = !!trigger.data.hierachical ? "hierarchical": "flat"; var[$account_name||"_owner"] = false; var[$account_name||"_balance"] += trigger.output[[asset=base]].amount; response['message'] = $account_name||" activated ^^"; }" } ] }, { "if": "{ trigger.data.pay_to}", "init": "{ // bouncing if (!var[$account_name]) bounce ("Account "||$account_name||" do not exist!"); if (!var[$LIST_HOLDER_AA][$account_name||"_"||trigger.address]) bounce ("This address is not listed as actor of this account"); if (!is_valid_address(trigger.data.pay_to)) bounce ("Invalid address in 'pay_to'!"); if (!is_valid_amount(trigger.data.amount)) bounce ("amount must be positive !"); // initiate payment request $payment_id = sha256($account_name||'>'||$pay_address||': '||$pay_amount); }", "messages": [ { "app": "data", "payload": { "get_previous ": "{ true }", "token": "{ $payment_id }" } }, { "if": "{$last != trigger.address}", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $LIST_HOLDER_AA }", "amount": 1000 } ] } }, { "app": "state", "state": "{ $nickname = var[$LIST_HOLDER_AA][$account_name||"_"||trigger.address]; var[$payment_id] = "Payment of "||trigger.data.amount||" bytes from "||$account_name||" to "||trigger.data.pay_to||" initiated by "||trigger.address||"("||$nickname||")"; var[$payment_id||"_initiator"] = trigger.address; var[$payment_id||"_destination"] = trigger.data.pay_to; var[$payment_id||"_amount"] = trigger.data.amount; var[$payment_id||"_account"] = $account_name; var[$payment_id||"_communication"] = trigger.data.communication otherwise "none"; var[$payment_id||"_validation_needed"] = var[$LIST_HOLDER_AA][$account_name||"_items_count"]-1; response['message'] = "Payment "||$payment_id||" created and approvals requested"; }" } ] }, { "if": "{ trigger.data.cancel}", "init": "{ if (!var[$LIST_HOLDER_AA][$account_name||"_"||trigger.address]) bounce ("This address is not listed as actor of this account"); $payment_id = trigger.data.token otherwise bounce ("'Token' needed !"); $message = "Payment cancelled by "||trigger.address||", "||var[$payment_id]; }", "messages": [ { "app": "data", "payload": { "message": "{ $message }" } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ var[$payment_id||"_initiator"] }", "amount": 6 } ] } }, { "app": "state", "state": "{ var[$payment_id] = false; var[$payment_id||"_initiator"] = false; var[$payment_id||"_validation_needed"] = false; var[$payment_id||"_communication"] = false; var[$payment_id||"_destination"] = false; var[$payment_id||"_amount"] = false; var[$payment_id||"_account"] = false; var[$payment_id||"_needs_"||trigger.address] = false; var[$payment_id||"_destination"] = false; var[$payment_id||"_amount"] = false; response['message'] = $message; }" } ] }, { "if": "{ trigger.address == $LIST_HOLDER_AA }", "init": "{ // initiate payment request $payment_id = trigger.data.token; // get it back from HOLLAA $account_name = var[$payment_id||"_account"]; $party = trigger.data.item_name; $validation_needed = $party != var[$payment_id||"_initiator"]; $another_party_is_needed = $party != var[$LIST_HOLDER_AA][$account_name||"_first_item"]; $forwarding_needed = $another_party_is_needed and var[$account_name] == "flat"; }", "messages": [ { "if": "{ $validation_needed }", "app": "data", "payload": { "message": "{"JAAA: Your approval is required: "||var[$payment_id]||", please send me back the token linked to validate the transaction. And add a 'cancel = true' field to refuse it."}" } }, { "app": "data", "payload": { "token": "{ $payment_id }" } }, { "if": "{ $forwarding_needed }", "app": "data", "payload": { "get_previous ": "{ $party }" } }, { "if": "{ $forwarding_needed }", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $LIST_HOLDER_AA }", "amount": 1000 } ] } }, { "if": "{ $validation_needed }", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $party }", "amount": 1000 } ] } }, { "app": "state", "state": "{ var[$payment_id||"_needs_"||$party] = $validation_needed; }" } ] }, { "if": "{ trigger.data.token }", "init": "{ $payment_id = trigger.data.token; $account_name = var[$payment_id||"_account"]; // bouncings if (!var[$payment_id]) bounce ("Token "||$payment_id||" do not exist!"); if (!var[$LIST_HOLDER_AA][$account_name||"_"||trigger.address]) bounce ("This address is not listed as actor of this account"); if (!var[$payment_id||"_needs_"||trigger.address]) bounce ("Your validation is not needed!"); $validation_needed = var[$payment_id||"_validation_needed"]-1; $is_validated = $validation_needed == 0; $forwarding_needed = !$is_validated and var[$account_name] == "hierarchical"; }", "messages": [ { "if": "{ $is_validated }", "app": "data", "payload": { "message": "{ var[$payment_id||"_communication"] }" } }, { "if": "{ $is_validated }", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ var[$payment_id||"_destination"] }", "amount": "{ var[$payment_id||"_amount"] }" } ] } }, { "if": "{ $forwarding_needed }", "app": "data", "payload": { "token": "{ $payment_id }", "get_previous ": "{ $party }" } }, { "if": "{ $forwarding_needed }", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ var[$payment_id||"_destination"] }", "amount": "{ var[$payment_id||"_amount"] }" } ] } }, { "app": "state", "state": "{ var[$payment_id||"_needs_"||trigger.address] = false; var[$payment_id||"_validation_needed"] = $validation_needed; if ($is_validated) // clean the payment state { var[$payment_id] = false; var[$payment_id||"_initiator"] = false; var[$payment_id||"_communication"] = false; var[$payment_id||"_destination"] = false; var[$payment_id||"_amount"] = false; var[$payment_id||"_account"] = false; } }" } ] }, { "messages": [ { "app": "state", "state": "{ bounce ($INSTRUCTIONS); }" } ] } ] } } ]
Technical information
Fees:
9,246 bytes
(353 headers, 8893 payload)
Level:1073493
Witnessed level:1073486
Main chain index:1072258
Latest included mc index:1072257
Status:stable/confirmed/final