[
"autonomous agent",
{
"init": "{
$define = var[trigger.initial_unit] ? false : true;
}",
"messages": {
"cases": [
{
"if": "{$define}",
"init": "{
require(is_valid_amount(trigger.data.cap), "Cap is not a valid amount");
}",
"messages": [
{
"app": "asset",
"payload": {
"cases": [
{
"if": "{trigger.data.cap}",
"payload": {
"cap": "{trigger.data.cap}",
"is_private": false,
"is_transferrable": true,
"auto_destroy": false,
"fixed_denominations": false,
"issued_by_definer_only": true,
"cosigned_by_definer": false,
"spender_attested": false
}
},
{
"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,
"issue_condition": [
"or",
[
[
"address",
"{trigger.address}"
],
[
"address",
"{this_address}"
]
]
]
}
}
]
}
},
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "
5L7YJI2SMM5QHLWA3YVRZUSCEOM7NRL7",
"amount": 1000
}
]
}
},
{
"app": "data",
"payload": {
"name": "{trigger.data.name}",
"decimals": "{trigger.data.decimals OTHERWISE 0}"
}
},
{
"app": "state",
"state": "{
var[trigger.initial_unit] = response_unit;
var[trigger.initial_unit || "_cap"] = trigger.data.cap;
}"
}
]
},
{
"messages": [
{
"app": "payment",
"payload": {
"asset": "{var[trigger.initial_unit]}",
"outputs": [
{
"address": "{trigger.initial_address}",
"amount": "{var[trigger.initial_unit || "_cap"]}"
}
]
}
},
{
"app": "state",
"state": "{
var[trigger.initial_unit || "_cap"] = false;
var[trigger.initial_unit] = false;
}"
}
]
}
]
}
}
]