Unit ID
qGzdtpb2E9Jdsw6IR+WgkRaB3+1Z2YeEOo7Recv34sY=
Received
26.08.2019 20:25:08
Confirmation delay (full node)
6 minutes 17 seconds
Confirmation delay (light node)
9 minutes 51 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ // Owner of the AA can withdraw the dust if calculable $OWNER = "MYESSCFGDERS3YIEGNZDOG2BI5HKQHLU"; // Variable for the unnit testing $UT_ACCOUNT_NAME = "toietmoi"; $UT_OTHER_PARTY_ADDRESS = "35IT3ZYKEPQSCXG2F7A7KWNRAD3SZXN4"; }", "messages": { "cases": [ { "if": "{ trigger.data.1 }", "messages": [ { "app": "data", "payload": { "create": "{ $UT_ACCOUNT_NAME }", "other_party": "{ $UT_OTHER_PARTY_ADDRESS }" } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{this_address}", "amount": "{trigger.output[[asset=base]] -1000}" } ] } } ] }, { "if": "{ trigger.data.2 }", "messages": [ { "app": "data", "payload": { "name": "{$account_name }", "amount": "{4000}" } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{this_address}", "amount": "{1}" } ] } } ] }, { "if": "{ trigger.data.create }", "init": "{ $name = trigger.data.create; $other_party = trigger.data.other_party otherwise bounce ("need 'other_party' address!"); }", "messages": [ { "app": "state", "state": "{ var[$name||"_party1"] = trigger.address; var[$name||"_party2"] = $other_party; var[$name||"_balance"] = trigger.output[[asset=base]]; if (var["blocked_balance"]) var["blocked_balance"] += trigger.output[[asset=base]]; else var["blocked_balance"] = trigger.output[[asset=base]]; response['message'] = "Done! Later, the parties will have to agree on how to spread the balance ("||trigger.output[[asset=base]]||") by sending the 'amount' they allow the other party to receive, if the sum of the 2 amounts is equal to the balance then the payment will be executed."; }" } ] }, { "if": "{ trigger.data.name }", "init": "{ $name = trigger.data.name; $balance = var[$name||"_balance"] otherwise bounce ("Guarantee name do not exist!"); $amount = trigger.data.amount otherwise bounce ("Need the 'amount' you allow the other party to receive!"); if ($amount > $balance) bounce ("The amount is bigger than the full balance!"); if (var[$name||"_party1"] == trigger.address) { $proposition1 = $amount; $proposition2 = var[$name||"_proposition2"] otherwise $balance; } if (var[$name||"_party2"] == trigger.address) { $proposition1 = var[$name||"_proposition1"] otherwise $balance; $proposition2 = $amount; } if (!($proposition1)) bounce ("You are not part of the agreement!"); $agreement_found = ( $proposition1 + $proposition2 ) == $balance; }", "messages": [ { "if": "{ $agreement_found }", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{var[$name||"_party1"]}", "amount": "{ $proposition2 - 500 }" }, { "address": "{var[$name||"_party2"]}", "amount": "{ $proposition1 - 500 }" }, { "address": "{trigger.address}", "amount": "{ trigger.output[[asset=base]]-2000 }" } ] } }, { "app": "state", "state": "{ if ($agreement_found) { // clear the full state var[$name||"_party1"] = false; var[$name||"_party2"] = false; var[$name||"_balance"] = false; var[$name||"_proposition1"] = false; var[$name||"_proposition2"] = false; var["blocked_balance"] -= ($proposition1 + $proposition2 - 1000); response['message'] = "Agreement found and funds sent back to parties ^^"; } else { // safe the proposition if (var[$name||"_party1"] == trigger.address) var[$name||"_proposition1"] = $amount; else var[$name||"_proposition2"] = $amount; response['message'] = "Proposition recorded ("||$amount||" bytes), the other party should set 'amount' to "|| ($balance - $amount)||" bytes to find agreement ^^"; } }" } ] }, { "init": "{ if (trigger.address != $owner) bounce ("you need to read the doc!"); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$owner}", "amount": "{ balance[base] - var["blocked_balance"] - 1000 }" } ] } }, { "app": "state", "state": "{ response['message'] = "Dust sent to owner"; }" } ] } ] } } ]
Technical information
Fees:
4,000 bytes
(353 headers, 3647 payload)
Level:1027033
Witnessed level:1027026
Main chain index:1025846
Latest included mc index:1025845
Status:stable/confirmed/final