[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"messages": {
"cases": [
{
"if": "{!var['last_id']}",
"messages": [
{
"app": "state",
"state": "{
var['last_id'] = 1;
var['last_address'] = trigger.address;
var['last_timestamp'] = timestamp;
response['message'] = 'first,last_id:' || var['last_id'] || ',last_address' || var['last_address'] || ', last_timestamp' || var['last_timestamp'] || ',balance:' || balance[base];
}"
}
]
},
{
"if": "{
$times = timestamp - var['last_timestamp'];
$times < 600
}",
"messages": [
{
"app": "state",
"state": "{
var['last_address'] = trigger.address;
var['last_timestamp'] = timestamp;
response['message'] = 'go,last_id:' || var['last_id'] || ',last_address' || var['last_address'] || ', last_timestamp' || var['last_timestamp'] || ',balance:' || balance[base];
}"
}
]
},
{
"if": "{
$times = timestamp - var['last_timestamp'];
$times > 600
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ var['last_address'] }",
"amount": "{ balance[base] - trigger.output[[asset=base]]}"
}
]
}
},
{
"app": "state",
"state": "{
var['last_id'] = var['last_id'] + 1;
var['last_address'] = trigger.address;
var['last_timestamp'] = timestamp;
response['message'] = 'new,last_id:' || var['last_id'] || ',last_address' || var['last_address'] || ', last_timestamp' || var['last_timestamp'] || ',balance:' || balance[base];
}"
}
]
}
]
}
}
]