74NKN7XV7XNRMXJUZXTHPQU47QDNT2JG
[
"autonomous agent",
{
"init": "{
$release_fee = 1000;
$balance_key = 'balance_'||trigger.address;
response['info'] ="Welcome user! This AA allows to keep your bytes. Please add 'keep' data field with any value if you want to store bytes or 'release' data field if you want to withdraw previously deposited bytes. ";
}",
"messages": {
"cases": [
{
"if": "{trigger.data.keep}",
"messages": [
{
"app": "state",
"state": "{
var[$balance_key] = var[$balance_key] + trigger.output[[asset=base]];
response['message'] = trigger.output[[asset=base]] || ' bytes will be keeped.';
}"
}
]
},
{
"if": "{trigger.data.release AND var[$balance_key] >= $release_fee}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ var[$balance_key] - $release_fee}"
}
]
}
},
{
"app": "state",
"state": "{
response['message'] = var[$balance_key] - $release_fee|| ' bytes will be released. Transaction fee is'|| $release_fee || ' bytes';
var[$balance_key] = 0;
}"
}
]
},
{
"if": "{trigger.data.release}",
"messages": [
{
"app": "state",
"state": "{
bounce('The payment will be bounced. No bytes to release for this address or their amount is less than' || $release_fee || ' bytes fee.');
}"
}
]
},
{
"messages": [
{
"app": "state",
"state": "{
bounce("The payment will be bounced. Please add 'keep' or 'release' data field with any value.");
}"
}
]
}
]
}
}
]
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount