Definition: [
"autonomous agent",
{
"messages": {
"cases": [
{
"if": "{
$define_yes = trigger.data.define_yes AND !var['yes_asset'];
$define_no = trigger.data.define_no AND !var['no_asset'];
if ($define_yes AND $define_no)
bounce("can't define both assets at the same time");
$define_yes OR $define_no
}",
"messages": [
{
"app": "asset",
"payload": {
"is_private": false,
"is_transferrable": true,
"auto_destroy": false,
"fixed_denominations": false,
"issued_by_definer_only": false,
"cosigned_by_definer": false,
"spender_attested": false
}
},
{
"app": "state",
"state": "{
$asset = $define_yes ? 'yes_asset' : 'no_asset';
var[$asset] = response_unit;
response[$asset] = response_unit;
}"
}
]
},
{
"if": "{trigger.output[[asset=base]] >= 1e0 AND var['yes_asset'] AND var['no_asset']}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{var['yes_asset']}",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ trigger.output[[asset=base]] }"
}
]
}
},
{
"app": "payment",
"payload": {
"asset": "{var['no_asset']}",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ trigger.output[[asset=base]] }"
}
]
}
}
]
},
{
"if": "{(trigger.data.buyer == 'yes' OR trigger.data.buyer == 'no') AND !var['buyer']}",
"messages": [
{
"app": "state",
"state": "{
if (trigger.data.winner == 'yes' AND data_feed[[oracles='X55IWSNMHNDUIYKICDW3EOYAWHRUKANP', feed_name='BYTE_USD']] > 100)
var['buyer'] = 'yes';
else if (trigger.data.winner == 'no' AND timestamp > 1556668800)
var['buyer'] = 'no';
else
bounce('suggested outcome not confirmed');
response['buyer'] = trigger.data.buyer;
}"
}
]
},
{
"if": "{trigger.output[[asset!=base]] > 1000 AND var['buyer'] AND trigger.output[[asset!=base]].asset == var[var['buyer'] || 'asset']}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ trigger.output[[asset!=base]] }"
}
]
}
}
]
}
]
}
}
]