FHA3ZRV4S4CLSIYZFSVYALKOZYTMWS3Q
[
"autonomous agent",
{
"init": "{
$nom_AA = 'FOP';
$versio = '0.01';
//$_Registre = '5WVBJQHTEP54AEYUJGTQKWTXTXZSJQWA';
$_Registre = trigger.data._Registre; // * només x tests
$adr__ = trigger.initial_address;
$args = trigger.data;
$unitat_entrant = trigger.output[[ asset != base ]].asset;
// Retorna una dada del Registre
$__dada = $refdada =>
data_feed[[ oracles = $_Registre, feed_name = $refdada, ifnone = 0 ]];
// $_Portal = $__dada( '_Portal' );
$_Portal = trigger.address; // * només x tests
if ( $_Portal != trigger.address
AND $__dada( '_Accions' ) != trigger.address )
bounce( 'Accés interdit' );
$unitat_entrada = $args.unitat_entrada;
$unitat_sortida = $args.unitat_sortida;
$sentit = $args.sentit;
$id_estels = $__dada( 'Estels' );
$total_entrades = $__dada( 'total_entrades_' || $unitat_entrada ) otherwise 0;
$total_sortides = $__dada( 'total_sortides_' || $unitat_sortida ) otherwise 0;
$registre = {};
$dades = {};
if ( $sentit == 'entrada' OR $sentit == 'ambdos' ) {
$qt_entrada = trigger.output[[ asset = $args.id_unitat_entrada ]];
$nou_total_entrades = $total_entrades + $qt_entrada;
$ord_entrada = $__dada( 'ordinal_entrada' ) + 1;
$ref_entrada = 'entrada_' || $ord_entrada;
$dades[ $ref_entrada || '_data' ] = timestamp;
$dades[ $ref_entrada || '_emissora' ] = $adr__;
$dades[ $ref_entrada || '_unitat' ] = $unitat_entrada;
$dades[ 'total_entrades_' || $unitat_entrada ] = $nou_total_entrades;
$dades[ 'ordinal_entrada' ] = $ord_entrada;
}
if ( $sentit == 'sortida' OR $sentit == 'ambdos' ) {
$qt_sortida = $args.qt;
$rebedora = $args.rebedora;
$ord_sortida = $__dada( 'ordinal_sortida' ) + 1;
$ref_sortida = 'entrada_' || $ord_sortida;
$nou_total_sortides = $total_sortides + $qt_sortida;
$dades[ $ref_sortida || '_data' ] = timestamp;
$dades[ $ref_sortida || '_actuant' ] = $adr__;
$dades[ $ref_sortida || '_rebedora' ] = $rebedora;
$dades[ $ref_sortida || '_unitat' ] = $unitat_sortida;
$dades[ 'total_sortides_' || $unitat_sortida ] = $nou_total_sortides;
$dades[ 'ordinal_sortida' ] = $ord_sortida;
}
$registre.dades = $dades;
}",
"messages": [
{
"if": "{ $sentit == 'sortida' OR $sentit == 'ambdos' }",
"app": "payment",
"payload": {
"asset": "{ $unitat_sortida }",
"outputs": [
{
"address": "{ $rebedora }",
"amount": "{ $qt_sortida }"
}
]
}
},
{
"app": "data",
"payload": "{ $registre }"
},
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ $_Registre }",
"amount": "{ $__dada( 'Provisio' ) }"
}
]
}
},
{
"app": "state",
"state": "{
if ( $sentit == 'entrada' OR $sentit == 'ambdos' ) {
response[ $ref_entrada ] =
$qt_entrada || ' ' || $unitat_entrada || ' de ' || $adr__;
response[ 'Total entrades en ' || $unitat_entrada ] = $nou_total_entrades;
if( $unitat_entrada == 'Bytes' ) {
response[ 'Total entrades en MBytes' ] =
round ( $nou_total_entrades / 1e6 );
response[ 'Total entrades en GBytes' ] =
round ( $nou_total_entrades / 1e9 );
}
else if( $unitat_entrada != 'Estels' )
response[ 'Romanent en ' || $unitat_entrada ] =
balance[ this_address ][ $args.id_unitat_entrada ];
}
if ( $sentit == 'sortida' OR $sentit == 'ambdos' ) {
response[ $ref_sortida ] =
$qt_sortida || ' ' || $unitat_sortida || ' a ' || $rebedora;
response[ 'Total sortides en ' || $unitat_sortida ] = $nou_total_sortides;
}
response[ 'Romanent en Bytes' ] = balance[ this_address ][ base ];
response[ 'Romanent en MBytes' ] = round( balance[ this_address ][ base ] / 1e6 );
response[ 'Romanent en GBytes' ] = round( balance[ this_address ][ base ] / 1e9 );
response[ 'Romanent en Estels' ] = balance[ this_address ][ $id_estels ];
}"
}
]
}
]
- MCI: 2076448
- Not bounced
- Response unit:
- Response: {
"responseVars": {
"entrada_2": "50000000 Bytes de XD7FVUM442NPIIMLRIT2FYWJEDQ4ILLJ",
"Total entrades en Bytes": 50000000,
"Total entrades en MBytes": 50,
"Total entrades en GBytes": 0,
"Romanent en Bytes": 50000000,
"Romanent en MBytes": 50,
"Romanent en GBytes": 0,
"Romanent en Estels": 0
}
}
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount
14.07.2021 17:38:15
FHA3ZRV4S4CLSIYZFSVYALKOZYTMWS3Q
out
14.07.2021 17:38:15
in
FHA3ZRV4S4CLSIYZFSVYALKOZYTMWS3Q