Definition: [
"autonomous agent",
{
"init": "{
$registery_address = "URUPIH7QEV2LOCOZ73OXA46ARJZHB6QS";
if (trigger.data.asset_step AND trigger.address != $registery_address)
bounce("only registry can increment asset step");
if (trigger.data.define_assets)
$asset_symbol= "hometeam";
else if (trigger.data.asset_step == 1)
$asset_symbol= "awayteam";
else if (trigger.data.asset_step == 2)
$asset_symbol= "draw";
else if (trigger.data.asset_step == 3)
$asset_symbol= "canceled";
else if (trigger.data.asset_step == 4)
$issue = true;
if (!trigger.data.asset_step)
$next_asset_step = 1;
else if (trigger.data.asset_step < 4)
$next_asset_step = trigger.data.asset_step + 1;
}",
"messages": [
{
"if": "{$issue}",
"app": "payment",
"payload": {
"asset": "{var["hometeam"]}",
"outputs": [
{
"address": "{var['user_address']}",
"amount": "{var['amount_paid']}"
}
]
}
},
{
"if": "{$issue}",
"app": "payment",
"payload": {
"asset": "{var["awayteam"]}",
"outputs": [
{
"address": "{var['user_address']}",
"amount": "{var['amount_paid']}"
}
]
}
},
{
"if": "{$issue}",
"app": "payment",
"payload": {
"asset": "{var["draw"]}",
"outputs": [
{
"address": "{var['user_address']}",
"amount": "{var['amount_paid']}"
}
]
}
},
{
"if": "{$issue}",
"app": "payment",
"payload": {
"asset": "{var["canceled"]}",
"outputs": [
{
"address": "{var['user_address']}",
"amount": "{var['amount_paid']}"
}
]
}
},
{
"if": "{!$issue}",
"app": "asset",
"payload": {
"is_private": false,
"is_transferrable": true,
"auto_destroy": false,
"fixed_denominations": false,
"issued_by_definer_only": true,
"cosigned_by_definer": false,
"spender_attested": false
}
},
{
"if": "{!$issue}",
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{$registery_address}",
"amount": "{length($asset_symbol)*2 + 1000}"
}
]
}
},
{
"if": "{!$issue}",
"app": "data",
"payload": {
"next_asset_step": "{$next_asset_step}",
"asset_symbol": "{$asset_symbol}"
}
},
{
"if": "{!$issue}",
"app": "state",
"state": "{
var[$asset_symbol] = response_unit;
if (trigger.address != $registery_address){
var['user_address'] = trigger.address;
var['amount_paid'] = trigger.output[[asset=base]] - 10000;
}
}"
}
]
}
]