DILGS6UVDN56CHDNKG6BAKQG3AKPKO47
[
"autonomous agent",
{
"init": "{
$challenging_period = 30*24*3600;
$grace_period = 30*24*3600; // new assets can change their symbol immediately during this period after the first registration, if a new symbol got overwhelming support over the previous symbol
$overwhelming_multiplier = 5;
$amount = trigger.output[[asset=base]];
$drawer = trigger.data.drawer OTHERWISE 0;
if (!is_integer($drawer))
bounce("drawer must be integer");
if ($drawer != 0 AND $drawer != 1 AND $drawer != 7 AND $drawer != 30 AND $drawer != 90 AND $drawer != 180 AND $drawer != 360)
bounce("bad drawer: " || $drawer);
$symbol = trigger.data.symbol;
if ($symbol){
if (typeof($symbol) != 'string')
bounce("symbol must be string");
if ($symbol != to_upper($symbol))
bounce("symbol must be uppercase");
if (length($symbol) > 40)
bounce("symbol must be max 40 characters long");
if ($symbol == 'GBYTE' OR $symbol == 'MBYTE' OR $symbol == 'KBYTE' OR $symbol == 'BYTE' OR $symbol == 'TBYTE')
bounce("reserved symbol");
}
$description = trigger.data.description;
if ($description){
if (typeof($description) != 'string')
bounce("description must be string");
if (length($description) > 140)
bounce("description must be max 140 characters long");
}
$decimals = trigger.data.decimals;
if (exists($decimals)){
if (!is_integer($decimals))
bounce("decimals must be integer");
if ($decimals < 0 OR $decimals > 15)
bounce("decimals must be between 0 and 15");
}
$asset = trigger.data.asset;
if ($asset){
if (typeof($asset) != 'string')
bounce("asset must be string");
if (!asset[$asset].exists)
bounce("asset " || $asset || " does not exist");
}
}",
"messages": {
"cases": [
{
"if": "{ trigger.data.withdraw AND trigger.data.amount AND $asset AND $symbol }",
"init": "{
$drawer_key = trigger.address || '_' || $drawer || '_' || $symbol || '_' || $asset;
if (var[$drawer_key] < trigger.data.amount)
bounce("not enough funds in this drawer");
if ($drawer){
$expiry_ts = var[$drawer_key || '_expiry_ts'];
if ($expiry_ts AND timestamp < $expiry_ts)
bounce("warm-up period has not expired yet");
$allowed = !!$expiry_ts; // after expiry
}
else
$allowed = true;
}",
"messages": [
{
"if": "{$allowed}",
"app": "payment",
"payload": {
"outputs": [
{
"address": "{trigger.address}",
"amount": "{trigger.data.amount}"
}
]
}
},
{
"app": "state",
"state": "{
if ($allowed){
var[$drawer_key] -= trigger.data.amount;
if ($drawer)
var[$drawer_key || '_expiry_ts'] = false; // lock the drawer again
var['support_' || $symbol || '_' || $asset] -= trigger.data.amount; // if the support drops below some competitor, the current leader is not updated automatically, someone has to trigger the update with a new deposit (even a small one)
var['balance_' || trigger.address || '_' || $asset] -= trigger.data.amount;
$desc_hash = var['desc_choice_' || $asset || '_' || trigger.address];
if ($desc_hash)
var['desc_support_' || $asset || '_' || $desc_hash] -= trigger.data.amount;
}
else if (!$expiry_ts)
var[$drawer_key || '_expiry_ts'] = timestamp + $drawer * 24 * 3600;
}"
}
]
},
{
"if": "{$description AND exists($decimals) AND ($asset OR $symbol)}",
"init": "{
if ($asset)
$voted_asset = $asset;
else {
$voted_asset = var['s2a_' || $symbol];
if (!$voted_asset)
bounce("no asset found by symbol " || $symbol);
}
$balance = var['balance_' || trigger.address || '_' || $voted_asset];
if (!$balance)
bounce("you have no balance in this asset");
}",
"messages": [
{
"app": "state",
"state": "{
$desc_hash = sha256($description || $decimals);
if (!var['desc_' || $desc_hash]){ // a dictionary: description by its hash
var['desc_' || $desc_hash] = $description;
var['decimals_' || $desc_hash] = $decimals;
}
$previous_desc_hash = var['desc_choice_' || $voted_asset || '_' || trigger.address];
if ($previous_desc_hash) // remove support from the previous description
var['desc_support_' || $voted_asset || '_' || $previous_desc_hash] -= $balance;
var['desc_choice_' || $voted_asset || '_' || trigger.address] = $desc_hash;
var['desc_support_' || $voted_asset || '_' || $desc_hash] += $balance;
$current_desc_hash = var['current_desc_' || $voted_asset];
if (!$current_desc_hash OR $desc_hash != $current_desc_hash AND var['desc_support_' || $voted_asset || '_' || $desc_hash] > var['desc_support_' || $voted_asset || '_' || $current_desc_hash]){
var['current_desc_' || $voted_asset] = $desc_hash;
response['updated_support'] = var['desc_support_' || $voted_asset || '_' || $desc_hash];
response['message'] = "Your description is now the current";
}
}"
}
]
},
{
"if": "{trigger.data.move AND trigger.data.address AND $drawer AND $asset AND $symbol}",
"init": "{
$drawer_key = trigger.data.address || '_' || $drawer || '_' || $symbol || '_' || $asset;
$balance = var[$drawer_key];
if (!$balance)
bounce("nothing in this drawer");
$expiry_ts = var[$drawer_key || '_expiry_ts'];
if (!$expiry_ts)
bounce("warm-up period has not started yet");
if (timestamp < $expiry_ts)
bounce("warm-up period has not expired yet");
$drawer_0_key = trigger.data.address || '_0_' || $symbol || '_' || $asset;
}",
"messages": [
{
"app": "state",
"state": "{
var[$drawer_key] = false;
var[$drawer_0_key] += $balance;
var[$drawer_key || '_expiry_ts'] = false; // lock the (empty) drawer again
response['message'] = "Moved " || $balance || " to drawer 0";
}"
}
]
},
{
"if": "{$amount >= 1e8 AND $symbol AND $asset }",
"messages": [
{
"app": "state",
"state": "{
var['support_' || $symbol || '_' || $asset] += $amount;
$support = var['support_' || $symbol || '_' || $asset];
$current_asset = var['s2a_' || $symbol];
$current_symbol = var['a2s_' || $asset];
$current_asset_with_largest_support = var['by_largest_s2a_' || $symbol];
$current_symbol_with_largest_support = var['by_largest_a2s_' || $asset];
if ($current_asset AND !$current_asset_with_largest_support) // should never happen
bounce("no current asset by largest support?");
if ($current_symbol AND !$current_symbol_with_largest_support) // should never happen
bounce("no current symbol by largest support?");
// by symbol
if (!$current_asset_with_largest_support OR $current_asset_with_largest_support != $asset AND var['support_' || $symbol || '_' || $current_asset_with_largest_support] < $support)
var['by_largest_s2a_' || $symbol] = $asset;
$symbol_challenge_expiry_ts = var['expiry_ts_' || $symbol];
if (!$current_asset){ // the symbol is not taken yet
$s2a_ready = true;
}
else if ($current_asset != $asset AND var['support_' || $symbol || '_' || $current_asset] < $support){
if (!$symbol_challenge_expiry_ts) // start a challenging period
var['expiry_ts_' || $symbol] = timestamp + $challenging_period;
else if (timestamp > $symbol_challenge_expiry_ts AND var['by_largest_s2a_' || $symbol] == $asset){
$s2a_ready = true;
}
}
else if ($current_asset == $asset AND var['by_largest_s2a_' || $symbol] == $asset AND $symbol_challenge_expiry_ts AND timestamp > $symbol_challenge_expiry_ts)
var['expiry_ts_' || $symbol] = false;
// by asset
if (!$current_symbol_with_largest_support OR $current_symbol_with_largest_support != $symbol AND var['support_' || $current_symbol_with_largest_support || '_' || $asset] < $support)
var['by_largest_a2s_' || $asset] = $symbol;
$asset_challenge_expiry_ts = var['expiry_ts_' || $asset];
$current_symbol_support = var['support_' || $current_symbol || '_' || $asset];
if (!$current_symbol){
$a2s_ready = true;
}
else if ($current_symbol != $symbol AND $current_symbol_support < $support){
$has_largest_support = (var['by_largest_a2s_' || $asset] == $symbol);
$has_overwhelming_support = ($support > $overwhelming_multiplier * $current_symbol_support);
$immediate = $has_largest_support AND $has_overwhelming_support AND timestamp < var['grace_expiry_ts_' || $asset];
if (!$asset_challenge_expiry_ts){ // start a challenging period or apply the change immediately
if ($immediate){
$a2s_ready = true;
}
else
var['expiry_ts_' || $asset] = timestamp + $challenging_period;
}
else if ((timestamp > $asset_challenge_expiry_ts OR $immediate) AND $has_largest_support){
$a2s_ready = true;
}
}
else if ($current_symbol == $symbol AND var['by_largest_a2s_' || $asset] == $symbol AND $asset_challenge_expiry_ts AND timestamp > $asset_challenge_expiry_ts)
var['expiry_ts_' || $asset] = false;
// only update both links at the same time
if ($s2a_ready AND $a2s_ready){
// tear old links
if ($current_asset)
var['a2s_' || $current_asset] = false;
if ($current_symbol)
var['s2a_' || $current_symbol] = false;
// create both new links
var['s2a_' || $symbol] = $asset;
var['a2s_' || $asset] = $symbol;
response[$symbol] = $asset;
response[$asset] = $symbol;
if ($symbol_challenge_expiry_ts)
var['expiry_ts_' || $symbol] = false;
if ($asset_challenge_expiry_ts)
var['expiry_ts_' || $asset] = false;
if (!var['grace_expiry_ts_' || $asset]) // first registration
var['grace_expiry_ts_' || $asset] = timestamp + $grace_period;
}
$drawer_key = trigger.address || '_' || $drawer || '_' || $symbol || '_' || $asset;
var[$drawer_key] += $amount;
response[$drawer_key] = $amount;
if ($drawer)
var[$drawer_key || '_expiry_ts'] = false; // abort any timers for this drawer
var['balance_' || trigger.address || '_' || $asset] += $amount;
$desc_hash = var['desc_choice_' || $asset || '_' || trigger.address];
if ($desc_hash)
var['desc_support_' || $asset || '_' || $desc_hash] += $amount;
}"
}
]
}
]
}
}
]
- MCI: 1285464
- Not bounced
- Response: {
"responseVars": {
"RUB": "Zq3ojiLSZdebNNyR6u1QomZHzNTTgHEoIYlnDl9enaQ=",
"Zq3ojiLSZdebNNyR6u1QomZHzNTTgHEoIYlnDl9enaQ=": "RUB",
"AFVAFTQHJ47TDGEEP4J7ATQ7DD3B2ABX_0_RUB_Zq3ojiLSZdebNNyR6u1QomZHzNTTgHEoIYlnDl9enaQ=": 100000000
},
"info": "no messages after filtering"
}
- MCI: 1284612
- Not bounced
- Response: {
"responseVars": {
"USD_20200428": "gTxlaxP5J8xbs/nxipWgN9xEO2wV6qjEpJ7I8m4xVc0=",
"gTxlaxP5J8xbs/nxipWgN9xEO2wV6qjEpJ7I8m4xVc0=": "USD_20200428",
"EJC4A7WQGHEZEKW6RLO7F26SAR4LAQBU_0_USD_20200428_gTxlaxP5J8xbs/nxipWgN9xEO2wV6qjEpJ7I8m4xVc0=": 100000000
},
"info": "no messages after filtering"
}
- MCI: 1284524
- Not bounced
- Response: {
"responseVars": {
"USD_20200409": "I1GvdQ3BBr71C80khJwLiGKXvT/vgbrAMm79yHeqHiQ=",
"I1GvdQ3BBr71C80khJwLiGKXvT/vgbrAMm79yHeqHiQ=": "USD_20200409",
"EJC4A7WQGHEZEKW6RLO7F26SAR4LAQBU_0_USD_20200409_I1GvdQ3BBr71C80khJwLiGKXvT/vgbrAMm79yHeqHiQ=": 100000000
},
"info": "no messages after filtering"
}
- MCI: 1279323
- Not bounced
- Response: {
"responseVars": {
"TS": "k0rLU5j9UwaptrOD86CLVOL3tBEtFavXgPiFUBelZHE=",
"k0rLU5j9UwaptrOD86CLVOL3tBEtFavXgPiFUBelZHE=": "TS",
"AFVAFTQHJ47TDGEEP4J7ATQ7DD3B2ABX_0_TS_k0rLU5j9UwaptrOD86CLVOL3tBEtFavXgPiFUBelZHE=": 100000000
},
"info": "no messages after filtering"
}
- MCI: 1279039
- Not bounced
- Response: {
"responseVars": {
"TCS": "Pf1AmYp03g5sFxNRaC9caQJHhnuSSUlCpzx0vMWgLvk=",
"Pf1AmYp03g5sFxNRaC9caQJHhnuSSUlCpzx0vMWgLvk=": "TCS",
"AFVAFTQHJ47TDGEEP4J7ATQ7DD3B2ABX_0_TCS_Pf1AmYp03g5sFxNRaC9caQJHhnuSSUlCpzx0vMWgLvk=": 100000000
},
"info": "no messages after filtering"
}
- MCI: 1271795
- Not bounced
- Response: {
"responseVars": {
"GBYTE_USD_20200321": "KSQvdM9bH9wPX2TGX7zjjdTjVoMW+/kmVTeBtW611g0=",
"KSQvdM9bH9wPX2TGX7zjjdTjVoMW+/kmVTeBtW611g0=": "GBYTE_USD_20200321",
"AFVAFTQHJ47TDGEEP4J7ATQ7DD3B2ABX_0_GBYTE_USD_20200321_KSQvdM9bH9wPX2TGX7zjjdTjVoMW+/kmVTeBtW611g0=": 100000000
},
"info": "no messages after filtering"
}
- MCI: 1268677
- Not bounced
- Response: {
"responseVars": {
"SC": "gJbfqJoc8BiAmH57hUA8sfCUcTvrBOX+WCahb1px1yU=",
"gJbfqJoc8BiAmH57hUA8sfCUcTvrBOX+WCahb1px1yU=": "SC",
"AFVAFTQHJ47TDGEEP4J7ATQ7DD3B2ABX_0_SC_gJbfqJoc8BiAmH57hUA8sfCUcTvrBOX+WCahb1px1yU=": 100000000
},
"info": "no messages after filtering"
}
- MCI: 1268604
- Bounced
- Response: {
"error": "neither case is true in messages"
}
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount
01.04.2020 09:29:25
in
DILGS6UVDN56CHDNKG6BAKQG3AKPKO47
31.03.2020 17:47:18
in
DILGS6UVDN56CHDNKG6BAKQG3AKPKO47
31.03.2020 17:07:20
in
DILGS6UVDN56CHDNKG6BAKQG3AKPKO47
26.03.2020 13:22:19
in
DILGS6UVDN56CHDNKG6BAKQG3AKPKO47
26.03.2020 09:45:49
in
DILGS6UVDN56CHDNKG6BAKQG3AKPKO47