65M3D5H3KQXF442XLQBCLYYS7WXDMBOU
[
"autonomous agent",
{
"init": "{
$f = 1000;
if(!trigger.data.safe) bounce ('please specifcy a safe name');
$balance_key = 'balance_' || trigger.data.safe;
$code_hashed_key = 'code_' || trigger.data.safe;
$input = trigger.output[[asset=base]];
}",
"messages": {
"cases": [
{
"if": "{trigger.data.set}",
"init": "{ if (var[$code_hashed_key]) bounce ("Safe already exists"); }",
"messages": [
{
"app": "state",
"state": "{
var[$code_hashed_key] = trigger.data.set;
response['sec'] = 'Code set for account' || trigger.data.safe;
var[$balance_key] = var[$balance_key] + $input;
response['message'] = 'accepted on account ' || trigger.data.safe || ': ' || $input || ' bytes';
}"
}
]
},
{
"if": "{trigger.data.code}",
"init": "{
if (!var[$code_hashed_key]) bounce ("safe doesn't exists");
if (sha256(trigger.data.code) != var[$code_hashed_key]) bounce ("Wrong code!");
}",
"messages": [
{
"init": "{
$total = var[$balance_key] + $input - $f;
}",
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{$total}"
}
]
}
},
{
"app": "state",
"state": "{
var[$balance_key] = 0;
var[$code_hashed_key] = false;
response['message'] = 'withdrawn from account ' || trigger.data.safe || '. ';
}"
}
]
}
]
}
}
]
MCI: 1000979 Bounced Response: {
"error": "Wrong code!"
} MCI: 1000974 Bounced Response: {
"error": "Wrong code!"
} MCI: 1000966 Bounced Response unit: Response: {
"error": "Safe already exists"
} MCI: 1000939 Not bounced Response: {
"responseVars": {
"sec": "Code set for accountsafe",
"message": "accepted on account safe: 10000 bytes"
},
"error": "no messages after filtering"
} Show transactions in assets: All bytes
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount
15.08.2019 21:51:53
in
65M3D5H3KQXF442XLQBCLYYS7WXDMBOU
15.08.2019 21:51:22
in
65M3D5H3KQXF442XLQBCLYYS7WXDMBOU
15.08.2019 21:49:51
65M3D5H3KQXF442XLQBCLYYS7WXDMBOU
out
15.08.2019 21:49:51
in
65M3D5H3KQXF442XLQBCLYYS7WXDMBOU
15.08.2019 21:37:27
in
65M3D5H3KQXF442XLQBCLYYS7WXDMBOU