QM5A52FY3O2WJW7PIZ65DZW7S7AEJUMS
[
"autonomous agent",
{
"init": "{
$banker = 'JBGMJI7XSKLKNHZF26BUBWHVUZSDV3P5';
$base_key = 'balance_'||trigger.address;
$f = 1000;
$secret_key = 'secret_'||trigger.address;
}",
"messages": {
"cases": [
{
"if": "{
$secret = trigger.data.secret;
$total = var[$base_key]+trigger.output[[asset=base]]-$f;
$w_addr = trigger.data.addr;
$secret AND $w_addr AND var[$secret_key] AND sha256($secret) == var[$secret_key]
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{$w_addr}",
"amount": "{$total}"
}
]
}
},
{
"app": "state",
"state": "{
var['total'] = var['total']-var[$base_key];
var[$base_key] = 0;
response['message'] = 'withdrawn:' || $total|| ' bytes';
}"
}
]
},
{
"if": "{trigger.data.set_secret AND !var[$secret_key]}",
"messages": [
{
"app": "state",
"state": "{
var[$secret_key]=trigger.data.set_secret;
response['sec'] = 'secret setted ok';
var['total'] = var['total']+trigger.output[[asset=base]];
var[$base_key] = var[$base_key] + trigger.output[[asset=base]];
response['message'] = 'accepted:' || trigger.output[[asset=base]] || ' bytes' ;
}"
}
]
},
{
"if": "{
$allowed = balance[base]-trigger.output[[asset=base]]-var['total']-$f;
$total = $allowed+trigger.output[[asset=base]];
$banker == trigger.address AND trigger.data.withdraw AND $allowed > 0
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{$total}"
}
]
}
}
]
},
{
"messages": [
{
"app": "state",
"state": "{
var['total'] = var['total']+trigger.output[[asset=base]];
var[$base_key] = var[$base_key] + trigger.output[[asset=base]];
response['message'] = 'accepted:' || trigger.output[[asset=base]] || ' bytes' ;
}"
}
]
}
]
}
}
]
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount