Unit ID
+mB3Ce4yjTkNuXgl5v2mXOo6cvROUcGNjJ7jfYXTXjY=
Received
19.09.2019 10:23:14
Confirmation delay (full node)
1 minute 56 seconds
Confirmation delay (light node)
3 minutes 17 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $who = "HFNBIQTUNVMRM7PDP6NT2QRKLR62FOGR" ; $day = "27" ; // must be in ISO8601 format, with two digits $month = "09" ; // must be in ISO8601 format, with two digits // Time for Birthday Fiddle by [email protected] // usage: // friends or strangers can contribute to the annual fiddle fund anytime // the person who has birthday can release the fiddle every year on their birthday to fullfil their wishes // to release surprise - just send a transaction anytime after the birthday to get the previous year's surprise // the AA will also keep track of lifetime accumulated amount // setup: // set the person who has birthday address, day and month ( year might be a secret ) above // maybe better to use real attestation, but let's keep it simple for now $today = timestamp ; $today_string = timestamp_to_string( $today , "date" ) ; $fee = 1000 ; $surprise = var[ "surprise" ] otherwise ( balance[ base ] - $fee ) ; $fiddle = var[ "fiddle" ] otherwise 1 ; }", "messages": [ { "if": "{ trigger.address != $who }", "app": "data", "payload": { "friend": "{ trigger.address }" } }, { "if": "{ trigger.address == $who AND ( balance[ base ] - $surprise - $fee ) > 0 }", "app": "payment", "payload": { "cases": [ { "if": "{ $today <= $fiddle }", "payload": { "asset": "base", "outputs": [ { "address": "{$who}", "amount": "{ balance[ base ] - $surprise - $fee }" } ] } }, { "if": "{ $today > $fiddle }", "payload": { "asset": "base", "outputs": [ { "address": "{$who}", "amount": "{ balance[ base ] - $fee }" } ] } } ] } }, { "app": "state", "state": "{ // TIME GATE TECHNIQUE if( $today > $fiddle ){ // THE FIDDLE PLAYED var[ "surprise" ] = trigger.output[[asset=base]] - $fee ; // START NEW SURPRISE $year = json_parse( substring( $today_string , 0 , 4 ) ) + 1 ; // GET NEXT YEAR var[ "fiddle" ] = parse_date( $year || "-" || $month || "-" || $day ) ; // MOVE FIDDLE TO NEXT YEAR } else var[ "surprise" ] += trigger.output[[asset=base]] - $fee ; // ADD TO SURPRISE var[ "lifetime_amount" ] += trigger.output[[asset=base]] ; // hopefully the person didn't put in a lot of money himself, but we will never know if( trigger.address == $who AND ( $month || "-" || $day ) == substring( $today_string , 5 , 5 ) ) response[ "happy_birthday" ] = "may your wish come true" ; response[ "fiddle" ] = "will be played on " || timestamp_to_string( var[ "fiddle" ] ) ; }" } ] } ]
Technical information
Fees:
2,799 bytes
(353 headers, 2446 payload)
Level:1066580
Witnessed level:1066573
Main chain index:1065346
Latest included mc index:1065345
Status:stable/confirmed/final