Unit ID
SKJShFNQa5DiIo4QjNDXtlwKqEGe96PrrMfyxKPAPwQ=
Received
09.10.2019 18:44:34
Confirmation delay (full node)
7 minutes 32 seconds
Confirmation delay (light node)
10 minutes 33 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).!"; $ATTESTATOR = '35IT3ZYKEPQSCXG2F7A7KWNRAD3SZXN4'; // define var that are use in each use cases $name = trigger.data.register otherwise trigger.data.like otherwise trigger.data.dislike otherwise bounce ($INSTRUCTIONS); $popular_version_number = var[$name||"_"||"popular_version_number"]; }", "messages": { "cases": [ { "if": "{ !!trigger.data.register }", "init": "{ if (!!var[$name||"_owner"]) if (var[$name||"_owner"] != trigger.address) bounce ("You are not the owner !"); if (!trigger.data.address) bounce ("Please specify 'address' !"); $version_number = var[$name||"_last_version_number"] + 1 otherwise 1; }", "messages": [ { "app": "state", "state": "{ // for each AA we want to keep: var[$name||"_owner"] = trigger.address; // only user allow to update the AA var[$name||"_last_version_number"] = $version_number; var[$name||"_popular_version_number"] = $popular_version_number otherwise $version_number; // for each version we want to keep var[$name||"_"||$version_number||"_address"] = trigger.data.address; var[$name||"_"||$version_number||"_likes"] = 0; var[$name||"_"||$version_number||"_dislikes"] = 0; var[$name||"_"||$version_number||"_date"] = timestamp_to_string(timestamp); // add onwer to last voter so we dont have to test the state existance later var[$name||"_"||$version_number||"_last_voter"] = trigger.address; // response response['message'] = "New version of your aa has been registered ^^"; }" } ] }, { "if": "{ !!trigger.data.like or !!trigger.data.dislike}", "init": "{ if (attestation[[attestors=$ATTESTATOR, address=trigger.address, ifnone=false]] == false) bounce ("To like or dislike you must be attested by "||$ATTESTATOR); $version_number = trigger.data.version otherwise bounce ("Please specify 'version'"); if (!var[$name||"_"||$version_number||"_address"]) bounce ($name||"_"||$version_number||" do not exist !"); if (var[$name||"_"||$version_number||"_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 (trigger.data.like) var[$name||"_"||$version_number||"_likes"] += 1; if (trigger.data.dislike) var[$name||"_"||$version_number||"_dislikes"] += 1; // check if it became the most popular version if (var[$name||"_"||$version_number||"_likes"] - var[$name||"_"||$version_number||"_dislikes"] > var[$name||"_"||$popular_version_number||"_likes"] - var[$name||"_"||$popular_version_number||"_dislikes"]) { var[$name||"_popular_version_number"] = var[$name||"_"||$version_number]; } var[$name||"_"||$version_number||"_last_voter"] = trigger.address; response['message'] = "You vote has been taken into account ^^ "; }" } ] }, { "messages": [ { "app": "state", "state": "{ bounce ($INSTRUCTIONS); }" } ] } ] } } ]
Technical information
Fees:
3,935 bytes
(353 headers, 3582 payload)
Level:1099714
Witnessed level:1099706
Main chain index:1098474
Latest included mc index:1098473
Status:stable/confirmed/final