Unit ID
XWYP+txmb0g+QvfK8BYhnGvgaarGN85UFLfZ8h32+J0=
Received
05.10.2019 21:53:36
Confirmation delay (full node)
2 minutes 11 seconds
Confirmation delay (light node)
5 minutes 59 seconds
Messages
Definition
Definition: [ "autonomous agent", { "bounce_fees": { "base": 10000 }, "init": "{ }", "messages": { "cases": [ { "if": "{ !!trigger.data.store and !trigger.data.request_withdraw and !!trigger.data.hash_of_secret }", "init": "{ if (!!var[trigger.data.hash_of_secret]) // already existing in state bounce ("This hash already exist, choose another secret phrase to hash"); }", "messages": [ { "app": "state", "state": "{ $non_byte = trigger.output[[asset!=base]].asset; // return the asset if different than bytes $asset = ($non_byte != "none") ? $non_byte : "base"; // the asset is the non-byte if existing $amount = trigger.output[[asset=$asset]].amount; // get the amount of the asset. var[trigger.data.hash_of_secret] = $amount || " " || $asset; response['message'] = "Safely stored, to withdraw later, use 'withdraw = true' + 'hash_of_my_secret = <hash of secret phrase> and wait for messages in payment"; }" } ] }, { "if": "{ !!trigger.data.request_withdraw and !!trigger.data.hash_of_secret }", "init": "{ if (!var[trigger.data.hash_of_secret]) // not existing in state bounce ("This hash do not exist"); if (!!var[trigger.data.hash_of_secret||"_withdrawer"]) if (timestamp < var[trigger.data.hash_of_secret||"_Dead_line_timestamp"]) bounce ("There is a withdraw request in progress"); // determine a period in which this address can provide the secret phrase $dead_line = timestamp + 60*60 ; // add 1 hour }", "messages": [ { "app": "data", "payload": { "message": "{ "You have until "|| timestamp_to_string($dead_line, 'datetime') ||" to provide the secret key" }" } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ trigger.initial_address }", "amount": "{ 5 }" } ] } }, { "app": "state", "state": "{ if (!!var[trigger.data.hash_of_secret||"_withdrawer"]) // if outdated request exist var[var[trigger.data.hash_of_secret||"_withdrawer"]] = false; // remove it var[trigger.data.hash_of_secret||"_withdrawer"] = trigger.initial_address; var[trigger.data.hash_of_secret||"_Dead_line_timestamp"] = $dead_line; var[trigger.initial_address] = trigger.data.hash_of_secret; // initial to be able to work through other AA as well response['message'] = "You have until "|| timestamp_to_string($dead_line, 'datetime') ||" to provide the secret key"; }" } ] }, { "if": "{ !!trigger.data.proove_ownership and !!trigger.data.secret_phrase }", "init": "{ // waiting secret key from this address? if (!var[trigger.initial_address]) bounce ("Attention!, I'm not ready to receive your secret phrase, don't send it or it can compromised"); $hash = var[trigger.initial_address]; // check if it is not to late if (timestamp > var[$hash||"_Dead_line_timestamp"]) bounce ("Too late! don't send you secret phrase!, use 'withdraw' + 'hash_of_my_secret' again"); // check that the secret phrase is valid: if (sha256(trigger.data.secret_phrase) != $hash) bounce ("The secret phrase hash does not match with the one previously given"||$hash||" "||sha256(trigger.data.secret_phrase)); // prepare asset and amount to withdraw $separator_position = index_of(var[$hash], " "); $withdraw_amount = substring(var[$hash], 0, $separator_position); $withdraw_asset = substring(var[$hash], $separator_position); }", "messages": [ { "app": "payment", "payload": { "asset": "{ "base" }", "outputs": [ { "address": "{ trigger.initial_address }", "amount": "{ 3 }" } ] } }, { "app": "state", "state": "{ response['message'] = $withdraw_amount || " Funds sent "|| $withdraw_asset; // delete all states var[trigger.initial_address] = false; var[trigger.initial_address||"_Dead_line_timestamp"] = false; var[$hash||"_withdrawer"]=false; var[$hash||"_Dead_line_timestamp"]=false; response['message'] = "Funds sent"; }" } ] }, { "if": "{ !!trigger.data.store }", "messages": [ { "app": "state", "state": "{ bounce ("Instruction: Add 'hash_of_secret = <hash>, to create hash, choose a secret phrase (max length of 1024 char) and pass it through a sha256 hasher that encode in base64."); }" } ] }, { "if": "{ !!trigger.data.request_withdraw }", "messages": [ { "app": "state", "state": "{ bounce ("Instruction: Add 'hash_of_secret = <hash of the secret phrase>."); }" } ] }, { "if": "{ !!trigger.data.proove_ownership }", "messages": [ { "app": "state", "state": "{ bounce ("Instruction: Add 'secret_phrase = <clear secret phrase>."); }" } ] }, { "messages": [ { "app": "state", "state": "{ bounce ("Instruction: First choose what to do, 'store=true' to store some funds, 'request_withdraw=true' to initiate a withdraw or 'proove_ownership=true' then follow next instructions"); }" } ] } ] } } ]
Technical information
Fees:
5,780 bytes
(353 headers, 5427 payload)
Level:1093507
Witnessed level:1093500
Main chain index:1092268
Latest included mc index:1092267
Status:stable/confirmed/final