F2PVVZQUHDW3L33Z6CV6K4VMZC6MGG4K
[
"autonomous agent",
{
"messages": [
{
"if": "{
$who = "
HFNBIQTUNVMRM7PDP6NT2QRKLR62FOGR";
trigger.data.address == $who
}",
"app": "data",
"payload": {
"friend": "{trigger.data.address}"
}
},
{
"if": "{ trigger.data.address == $who AND ( balance[ base ] - $present ) > 0 }",
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{$who}",
"amount": "{ balance[ base ] - $present }"
}
]
}
},
{
"app": "state",
"state": "{
if( $today > $fiddle ){ // THE FIDDLE PLAYED
var[ "present" ] = 0 ; // START NEW PRESENT
var[ "fiddle" ] = $today + 60 * 3 ; // TESTING
$year = substring( timestamp_to_string( $today , "date" ) , 0 , 4 ) + 1 ;
response[ "year" ] = $year;
//var[ "fiddle" ] = parse_date( $year || "-" || $month || "-" || $day ); // MOVE FIDDLE TO NEXT BIRTHDAY
if( trigger.data.address == $who ) response[ "happy_birthday" ] = "send one more transaction to get your present";
} else var[ "present" ] += trigger.output[[asset=base]] - $storage ; // ADD TO PRESENT
var[ "lifetime_amount" ] += trigger.output[[asset=base]] ;
// hopefully the person didn't put in a lot of money himself, but we will never know
response[ "fiddle" ] = "will be played on " || timestamp_to_string( var[ "fiddle" ] ) ;
}"
}
]
}
]
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount