[
"autonomous agent",
{
"init": "{\r
$fee = 650;\r
if(var['asset']){\r
if(trigger.output[[asset!=base]].asset != 'none')\r
$asset = trigger.output[[asset!=base]].asset;\r
if($asset AND $asset == 'ambiguous') bounce('Only 1 asset per tx');\r
if($asset AND $asset != var['asset']) bounce('You must send '||var['asset']);\r
}\r
}",
"messages": {
"cases": [
{
"if": "{!var['asset']}",
"messages": [
{
"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
}
},
{
"app": "state",
"state": "{ var['asset'] = response_unit; }"
}
]
},
{
"if": "{$asset}",
"messages": [
{
"init": "{$a = trigger.output[[asset=base]]+trigger.output[[asset!=base]]-$fee;\r
$amount = balance[base] > $a ? $a:''; }",
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{$amount}"
}
]
}
},
{
"app": "state",
"state": "{ \r
response['message'] = 'sent bytes in exchange for dummy asset';\r
}"
}
]
},
{
"messages": [
{
"app": "payment",
"payload": {
"asset": "{var['asset']}",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{trigger.output[[asset=base]]-$fee}"
}
]
}
},
{
"app": "state",
"state": "{ \r
response['message'] = 'sent dummy asset in exchange for bytes';\r
}"
}
]
}
]
}
}
]