[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"init": "{
$this = {
dust_collector : "
B2UMBICLZSBVDHRC7BYM6BBU4AQEXL2F",
};
}",
"messages": {
"cases": [
{
"if": "{ !!var["refunded"] or !!var["withdrawn"]}",
"messages": [
{
"if": "{trigger.initial_address == $this.dust_collector}",
"app": "payment",
"payload": {
"asset": "{"base"}",
"outputs": [
{
"address": "{$this.dust_collector}",
"amount": "{balance[base]-1000}"
}
]
}
},
{
"app": "state",
"state": "{ response['message'] = 'Thank you for this donation!'; }"
}
]
},
{
"if": "{ timestamp > json_parse(params.deadline) }",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{var[trigger.initial_address||"_asset"]}",
"outputs": [
{
"address": "{trigger.initial_address}",
"amount": "{json_parse(var[trigger.initial_address||"_amount"])}"
}
]
}
},
{
"app": "state",
"state": "{
var["refunded"] = true; // that allows donation to developper
response['message'] = 'Time out, bytes sent back to owner.';
}"
}
]
},
{
"if": "{ trigger.initial_address == params.destination_address }",
"init": "{
$message = "You have been recognized but ";
if (!trigger.data.secret) bounce ($message||"you have to provide the 'secret' revealed on the other chain");
if (sha256(trigger.data.secret) != params.hash_of_secret) bounce ($message||"the secret is not good.");
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{params.destination_address}",
"amount": "{balance[params.asset_id]-1000}"
}
]
}
},
{
"app": "state",
"state": "{
var["withdrawn"] = true; // that allows donation to developper
response['message'] = 'Transfer successfull! Please donate by sending Gbytes to this address to support developpers';
}"
}
]
},
{
"messages": [
{
"app": "state",
"state": "{
$other_asset = trigger.output[[asset!=base]].asset;
$asset = $other_asset != "none" ? $other_asset : "base";
if (params.asset_id != $asset)
bounce ("Wrong asset, "||params.asset_id||" wanted (not "||$asset||").");
if (params.amount != 0)
if (trigger.output[[asset=$asset]].amount != params.amount)
bounce ("Wrong amount, "||params.amount||" wanted (not "||trigger.output[[asset=$asset]].amount||").");
response['message'] = 'Filled with '||trigger.output[[asset=$asset]].amount;
}"
}
]
}
]
}
}
]