[
"autonomous agent",
{
"init": "{
$aa_name = "DANAA"; // Dynamic Asset Names Autonomous Agent;
$owner = "
O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; // could withdraw the dust is calculable.
$unit_id = trigger.data.unit_id;
$short_name = trigger.data.short_name;
$ticker = trigger.data.ticker;
$issuer = trigger.address; // preferrably the address to be able to modify it
$name = trigger.data.name otherwise $short_name||" by "||$issuer;
}",
"messages": {
"cases": [
{
"if": "{ $unit_id and $short_name and $ticker}",
"init": "{
// check decimal
if (trigger.data.decimals)
{
if (trigger.data.decimals < 0)
bounce ("'decimals' must be > 0 !");
else
$decimals = trigger.data.decimals;
}
else
$decimals = 0;
// if exist must be issuer.
if (var[$unit_id])
if (trigger.address != var[$unit_id||"_issuer"])
bounce ("Already registered and not by you !");
$description = trigger.data.description otherwise "Asset called "||$short_name||" issued by "||$issuer||", with "||$decimals||" decimals available. Its ticker is "||$ticker||" and it is defined by the unit '"||$unit_id||"'.";
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{'base'}",
"outputs": [
{
"address": "{$issuer}",
"amount": "{trigger.output[[asset=base]] - 1000}"
}
]
}
},
{
"app": "state",
"state": "{
var[$unit_id||"_shortName"] = $short_name;
var[$unit_id||"_issuer"] = $issuer;
var[$unit_id||"_name"] = $name;
var[$unit_id||"_ticker"] = $ticker;
var[$unit_id||"_decimals"] = $decimals;
var[$unit_id||"_description"] = $description;
}"
}
]
},
{
"messages": [
{
"app": "state",
"state": "{
bounce ("Specify the following fields: 'unit_id', 'shortname', 'ticker', 'decimal' and optionaly 'name, and description' that can be by default built from the previous fields.");
}"
}
]
}
]
}
}
]