Unit ID
M9C1+hPcGcwBFLo1AD8Bb9HrIFm3pR5fNCFT33W5Ixg=
Received
29.08.2019 20:48:33
Confirmation delay (full node)
2 minutes 59 seconds
Confirmation delay (light node)
7 minutes 6 seconds
Messages
Definition
Definition: [ "autonomous agent", { "bounce_fees": { "base": 10000 }, "init": "{ $aa_name = "SAAFE"; // Safe Autonomous Agent Forwarding Estate; $aa_owner = "O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; // could withdraw the dust is calculable; $danaa = "LLAVLVFN3CPBHTAB62NOIZLAMPABR2YF"; // Dynamic Asset Name AA; // Reconstitute the public key by concataining the 2 given parts $puk_part1 = trigger.data.puk1 otherwise ""; $puk_part2 = trigger.data.puk2 otherwise ""; $puk_part3 = trigger.data.puk3 otherwise ""; $puk_part4 = trigger.data.puk4 otherwise ""; $puk = $puk_part1 || $puk_part2|| $puk_part3|| $puk_part4; $puk_received = ($puk != ""); // Reconstitute the signature by concataining the 2 given parts $s_part1 = trigger.data.s1 otherwise ""; $s_part2 = trigger.data.s2 otherwise ""; $s_part3 = trigger.data.s3 otherwise ""; $s_part4 = trigger.data.s4 otherwise ""; $signature = $s_part1 || $s_part2|| $s_part3 || $s_part4; $signature_received = $signature != ""; // Asset detection $received_unbase_asset = trigger.output[[asset!=base]].asset; $received_asset = ($received_unbase_asset != "none")? $received_unbase_asset : "base"; $asset = trigger.data.asset otherwise $received_asset; $asset_nice_name = var[$danaa][$asset||"_shortName"] otherwise $asset; // Drawer ID $drawer = sha256($puk||"_"||$asset); // to reduce size of the state var. // short names for state var. $dr = "drawer_"||$drawer; $am = $dr||"_amount"; $as = $dr||"_asset"; $pu = $dr||"_private_user"; $ls = "last_s_"||sha256($puk); // last signature used; }", "messages": { "cases": [ { "if": "{$puk_received and $signature_received and !trigger.data.withdraw_address}", "init": "{ // check if the public key selected is in a format accepted to avoid the coin to be stucked if (!is_valid_sig("safe", $puk, $signature)) bounce ("The fund cannot be safely store because the signature entered is note recognise as sign message containing the word 'safe' please check the documation !"); }", "messages": [ { "app": "state", "state": "{ if (!var[$as] and trigger.data.private) // only at the creation, to avoid abuses var[$pu] = trigger.address; var[$am] += trigger.output[[asset=$asset]].amount; var[$as] = $asset; response['message'] = var[$am]||' '||$asset_nice_name||' are safe under the puk '||$puk; }" } ] }, { "if": "{ $puk_received and $signature_received and trigger.data.withdraw_address }", "init": "{ // checking if (var[$pu]) if (var[$pu] != trigger.address) bounce ("Not allowed to withdraw from this private drawer!"); if (!var[$as]) bounce ("puk doesn\'t exists with asset!"||$asset_nice_name); if (var[$ls]) if (var[$ls] == sha256($signature)) bounce ("Cannot use 2 times the same signature in a row!"); if (!is_valid_sig(trigger.data.withdraw_address, $puk, $signature)) bounce ("The 'withdraw address' signed is not the same as the one that was asked to use ! or this signature was not created with private key linked to "||$puk||" !"); // balances $old_balance = var[$am]; $amount = trigger.data.withdraw_amount otherwise $old_balance; }", "messages": [ { "app": "payment", "payload": { "asset": "{$asset}", "outputs": [ { "address": "{trigger.data.withdraw_address}", "amount": "{$amount}" } ] } }, { "app": "state", "state": "{ $new_balance = $old_balance - $amount; var[$am] = $new_balance; response['message'] = $amount||' of the '||$old_balance||' '||$asset_nice_name||' withdrawn from '||$puk||' to '|| trigger.data.withdraw_address; if ($new_balance == 0) // cleaning { var[$am] = false; var[$as] = false; var[$pu] = false; } else // storing last sign to avoid abuse var[$ls] = sha256($signature); //to reduce size }" } ] }, { "messages": [ { "app": "state", "state": "{ if(!($puk)) bounce ("To store or withdraw, you always have to set at least 'puk1' and 'puk2' to the 2 half of the public key, for which you have the related private key"); if(!($signature)) bounce ("To withdraw, set the puks fields, as well as an 'ad' field set to the Obyte adresse where you want to receive the funds and a 's1' and 's2' field set to ."); }" } ] } ] } } ]
Technical information
Fees:
5,478 bytes
(353 headers, 5125 payload)
Level:1033161
Witnessed level:1033153
Main chain index:1031973
Latest included mc index:1031972
Status:stable/confirmed/final