[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"init": "{
// forever constantes
$AA_NAME = "";
$AA_OWNER = ""; // could withdraw the dust is calculable.
$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 = "
IZEA5ZL5K3KBPMNK2OIH5WXRTVKB2OFE"; // to store jury and entries lists
$i = trigger.data;
$id = trigger.data.contest_name otherwise bounce ("Need the 'contest_name' ! ");
}",
"messages": {
"cases": [
{
"if": "{
!!trigger.data.create and
!!trigger.data.contest_name and
!!trigger.data.entry_dead_line and !!trigger.data.decision_dead_line}",
"init": "{
if (!!$i.debug) bounce ("variables you want to watch when you set 'debug' in preview mode of the wallet");
}",
"messages": [
{
"app": "state",
"state": "{
var[$id||"_owner"] = trigger.address;
var[$id||"_price"] = trigger.output[[asset=base]].amount - 2000;
var[$id||"_entry_dead_line"] = $i.entry_dead_line ;
var[$id||"_decision_dead_line"] = $i.decision_dead_line ;
}"
}
]
},
{
"if": "{ !!trigger.data.add_jury }",
"init": "{
$list = $id||"_jury";
if (!!var[$id||"_owner"])
if (var[$id||"_owner"] != trigger.address)
bounce ("Must be owner to add jury member !");
}",
"messages": [
{
"app": "data",
"payload": {
"list": "{ $list }",
"add": "{ $i.jury }"
}
},
{
"app": "payment",
"payload": {
"outputs": [
{
"address": "{$HOLAA}",
"amount": "{200}"
}
]
}
},
{
"app": "state",
"state": "{
response['added jury'] = var[$HOLAA][$list||"_"||var[$HOLAA][$list||"_count"]];
}"
}
]
},
{
"messages": [
{
"app": "state",
"state": "{ bounce ($INSTRUCTIONS);}"
}
]
}
]
}
}
]