Definition: [
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"init": "{
// forever constantes
$AA_NAME = "";
$INSTRUCTIONS = "To add your entry, use 'contest_name' and 'add_entry', to create a contest use 'create=true', 'contest_name=<contest unique name>, 'entry_dead_line'=<timestamp>, 'decision_dead_line'=<timestamp> and later use 'contest_name=<contest unique name> with 'add_jury=<jury_member_address>'";
$HOLAA = "GKLIQX4SNNU2URWDIX2F5NSWK4XJUNQY"; // to store jury and entries lists
$TARAA = "JM25GYLEP7ZZS5UTTND6AJUXQW6KJBHI"; // for voting
$AA_OWNER = "MYESSCFGDERS3YIEGNZDOG2BI5HKQHLU"; // could withdraw the dust is calculable.
$id = "contest_name";
$entry_dead_line = timestamp + 60*60*24*10;
$decision_dead_line = $entry_dead_line +60*60*24*3;
}",
"messages": {
"cases": [
{
"if": "{ !!trigger.data.add_jury and !var["price"] }",
"init": "{
$list = $id||"_jury";
}",
"messages": [
{
"app": "attestation",
"payload": {
"address": "{trigger.data.add_jury}",
"profile": {
"contest": "{$id}"
}
}
},
{
"app": "data",
"payload": {
"list": "{ $list }",
"add": "{ $i.jury }"
}
},
{
"app": "payment",
"payload": {
"outputs": [
{
"address": "{$HOLAA}",
"amount": "{200}"
}
]
}
},
{
"app": "state",
"state": "{
response['jury member added'] = var[$HOLAA][$list||"_"||var[$HOLAA][$list||"_count"]];
}"
}
]
},
{
"if": "{ !!trigger.data.start }",
"messages": [
{
"app": "data",
"payload": {
"domain": "{ $id }",
"attestor": "{ this_address }"
}
},
{
"app": "payment",
"payload": {
"outputs": [
{
"address": "{$TARAA}",
"amount": "{50000}"
}
]
}
},
{
"app": "state",
"state": "{
var["price"] = trigger.output[[asset=base]].amount - 52000;
var["owner"] = $AA_OWNER;
var["entry_dead_line"] = $entry_dead_line;
var["decision_dead_line"] = $decision_dead_line;
}"
}
]
},
{
"if": "{ !!trigger.data.add_entry and !!var["price"] and $entry_dead_line > timestamp }",
"init": "{ $list = $id||"_entries"; }",
"messages": [
{
"app": "data",
"payload": {
"list": "{ $list }",
"add": "{ trigger.address }",
"value": "{ trigger.data.entry }"
}
},
{
"app": "payment",
"payload": {
"outputs": [
{
"address": "{$HOLAA}",
"amount": "{200}"
}
]
}
}
]
},
{
"messages": [
{
"app": "state",
"state": "{ bounce ($INSTRUCTIONS);}"
}
]
}
]
}
}
]