Unit ID
EDRBJX6yzuov8Fa5l5Q9UHiDjm1OS/ksMJH4HLnpjaY=
Received
09.10.2019 17:29:23
Confirmation delay (full node)
3 minutes 25 seconds
Confirmation delay (light node)
7 minutes 28 seconds
Messages
Definition
Definition: [ "autonomous agent", { "bounce_fees": { "base": 10000 }, "init": "{ // forever constantes $INSTRUCTIONS = "Please use 'register = <aa name>'' + 'address = <aa address>' to add your AA as a new entry or to update with a new version. Please use '(dis)like' = <aa name> + 'version' = <version> to give your opinion on a version of an AA (you need to be attested by the real name attestor).!"; $AA_OWNER = "O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; $ATTESTATOR = '35IT3ZYKEPQSCXG2F7A7KWNRAD3SZXN4'; // see all possible inputs here: $register = trigger.data.register; $aa_address = trigger.data.address; $like = trigger.data.like; $dislike = trigger.data.dislike; $aa_version = trigger.data.version; $need_help = trigger.data.help otherwise trigger.data.h; // define var that are use in each use cases $name = trigger.data.register otherwise trigger.data.like otherwise trigger.data.dislike otherwise bounce ($INSTRUCTIONS); $aa_name = $name||"_"; $popular_version_number = var[$aa_name||"popular_version_number"]; }", "messages": { "cases": [ { "if": "{ !!$register }", "init": "{ if (!!var[$aa_name||"owner"]) if (var[$aa_name||"owner"] != trigger.address) bounce ("You are not the owner !"); if (!$aa_address) bounce ("Please specify 'address' !"); $version = var[$aa_name||"last_version_number"] + 1 otherwise 1; }", "messages": [ { "app": "state", "state": "{ // for each AA we want to keep: var[$aa_name||"owner"] = trigger.address; // only user allow to update the AA var[$aa_name||"last_version_number"] = $version; var[$aa_name||"popular_version_number"] = $popular_version_number otherwise $version; // for each version we want to keep var[$aa_name||$version||"_address"] = $aa_address; var[$aa_name||$version||"_likes"] = 0; var[$aa_name||$version||"_dislikes"] = 0; var[$aa_name||$version||"_date"] = timestamp_to_string(timestamp); // response response['message'] = "New version of your aa has been registered ^^"; }" } ] }, { "if": "{ !!$like or !!$dislike}", "init": "{ if (attestation[[attestors=$ATTESTATOR, address=trigger.address, ifnone=false]] == false) bounce ("To like or dislike you must be attested by "||$ATTESTATOR); $version = $aa_version otherwise bounce ("Please specify 'version'"); if (!var[$aa_name||$version||"_address"]) bounce ($aa_name||$version||" do not exist !"); if (var[$aa_name||$version||"_last_voter"] == trigger.address) bounce ("Cannot vote twice!"); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}", "amount": "{ trigger.output[[asset=base]]-1000 }" } ] } }, { "app": "state", "state": "{ // proceed voting if ($b_want_to_like) var[$aa_name||$version||"_likes"] += 1; if ($b_want_to_dislike) var[$aa_name||$version||"_dislikes"] += 1; // check if it became the most popular version if (var[$aa_name||$version||"_likes"] > var[$aa_name||$popular_version_number||"_likes"]) { var[$aa_name||"popular_version_number"] = var[$aa_name||$version]; } var[$aa_name||$version||"_last_voter"] = trigger.address; response['message'] = "You vote has been taken into account ^^ "; }" } ] }, { "messages": [ { "app": "state", "state": "{ bounce ($INSTRUCTIONS); }" } ] } ] } } ]
Technical information
Fees:
3,868 bytes
(353 headers, 3515 payload)
Level:1099498
Witnessed level:1099490
Main chain index:1098258
Latest included mc index:1098257
Status:stable/confirmed/final