ZHBLSKMDZ6YTEKTK5IBHFSRN6XWMR7IT
[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"init": "{
$aa_name = "CODAA_ASSET_MANAGER";
$howto = "I'm made to be used by machine, just review my code to know more";
$DEBUG = true;
$PERCENT = 0.01;
$SECOND = 1;
$MINUTES = 60;
$HOUR = 60 * $MINUTES;
$DAY = 24 * $HOUR;
$WEEK = 7 * $DAY;
$YEAR = 364.25 * $DAY;
}",
"messages": {
"cases": [
{
"if": "{ !!trigger.data.create}",
"init": "{
if (!!var[trigger.data.name])
bounce ("Already used!");
}",
"messages": [
{
"app": "asset",
"payload": {
"cap": "{ trigger.data.cap }",
"is_private": false,
"is_transferrable": true,
"fixed_denominations": false,
"auto_destroy": false,
"cosigned_by_definer": false,
"issued_by_definer_only": true,
"spender_attested": false
}
},
{
"app": "state",
"state": "{
var[trigger.data.name||"_id"] = response_unit;
var[trigger.data.name||"_owner"] = trigger.address;
var[trigger.data.name||"_creation_time"] = timestamp_to_string(timestamp);
var[trigger.data.name||"_balance"] = trigger.data.cap otherwise 1e15;
var[trigger.data.name||"_last_return_time"] = timestamp_to_string(timestamp);
var[trigger.data.name||"_return_period"] = trigger.data.period otherwise 1 * $YEAR;
var[trigger.data.name||"_return_percentage"] = trigger.data.percentage otherwise 4 * $PERCENT;
var[trigger.data.name||"_next_return"] =
var[trigger.data.name||"_balance"] * var[trigger.data.name||"_return_percentage"];
response["message"] = "Asset created";
}"
}
]
},
{
"if": "{ !!trigger.data.do_accounting }",
"init": "{
if (!!var[trigger.data.name])
bounce ("name needed!");
if (var[trigger.data.name||"_owner"] !=trigger.address and !$DEBUG)
bounce ("Not owner!");
if (timestamp<
parse_date(var[trigger.data.name||"_last_return_time"]) + var[trigger.data.name||"_return_period"])
bounce ("too early");
$return = var[trigger.data.name||"_balance"] * var[trigger.data.name||"_return_percentage"];
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{ var[trigger.data.name||"_id"] }",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ $return }"
}
]
}
},
{
"app": "state",
"state": "{
var[trigger.data.name||"_balance"] -= $return;
var[trigger.data.name||"_last_return_time"] = timestamp_to_string(timestamp);
var[trigger.data.name||"_last_return_time"] = timestamp_to_string(timestamp);
var[trigger.data.name||"_next_return"] =
var[trigger.data.name||"_balance"] * var[trigger.data.name||"_return_percentage"];
response["message"] = "return percentage sent.";
}"
}
]
},
{
"messages": [
{
"app": "state",
"state": "{ bounce($howto); }"
}
]
}
]
}
}
]
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount