Unit ID
FspkCY41TBrJ8oma9icVCj97GiFk+dvzDCCGnaAipcY=
Received
09.09.2019 20:30:42
Confirmation delay (full node)
3 minutes 43 seconds
Confirmation delay (light node)
5 minutes 9 seconds
Messages
Definition
Definition: [ "autonomous agent", { "bounce_fees": { "base": 10000 }, "init": "{ $BOUNCE_FEE = 10000; $TYPICAL_FEE = 1000; $REIMBURSEMENT = $BOUNCE_FEE - $TYPICAL_FEE; }", "messages": { "cases": [ { "if": "{ trigger.data.owner }", "init": "{ $owner = trigger.data.owner otherwise bounce("owner field is missing"); $period = trigger.data.period otherwise bounce("period field is missing"); $balance = 0; $reference = sha256($owner || $period || $balance || timestamp); if (var[$reference]) bounce("pension plan already exists"); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}", "amount": "{$REIMBURSEMENT}" } ] } }, { "app": "state", "state": "{ var[$reference] = 'requested'; var[$reference||'.owner'] = $owner; var[$reference||'.period'] = $period; var[$reference||'.balance'] = $balance; var[$reference||'.timestamp'] = timestamp; response['reference'] = $reference; response['message'] = 'Pension plan created'; response['creation_time'] = var[$reference||'.timestamp']; response['balance'] = var[$reference||'.balance']; }" } ] }, { "if": "{trigger.data.deposit AND trigger.output[[asset = base]] > $BOUNCE_FEE}", "init": "{ $reference = trigger.data.reference otherwise bounce("pension plan reference is missing"); $balance = var[$reference||'.balance']; $deposit = trigger.output[[asset = base]] - $TYPICAL_FEE; $newbalance = $balance + $deposit; }", "messages": [ { "app": "state", "state": "{ var[$reference||'.balance'] = $newbalance; response['message'] = 'Added ' || $deposit || ' bytes to the private pension plan ' || $reference ||'.'; response['balance'] = 'The current balance of pension plan ' || $reference || 'is ' || $newbalance ||'.'; }" } ] }, { "if": "{trigger.data.withdraw}", "init": "{ $reference = trigger.data.reference otherwise bounce("pension plan reference is missing"); $balance = var[$reference||'.balance']; $amount = trigger.data.amount otherwise $balance; $newbalance = $balance - $amount; if ($newbalance < 0) bounce("Invalid withdrawal amount. Maximum balance is " || $balance || '.'); if ($amount <= 0) bounce("Invalid withdrawal amount. Enter a number greater than zero."); if (trigger.address != var[$reference||'.owner']) bounce("Unauthorized"); }", "messages": { "cases": [ { "if": "{timestamp > (var[$reference||'.timestamp'] + var[$reference||'.period'])}", "messages": [ { "app": "payment", "payload": { "outputs": [ { "address": "{var[$reference||'.owner']}", "amount": "{$amount}" }, { "address": "{var[$reference||'.owner']}", "amount": "{$REIMBURSEMENT}" } ] } }, { "app": "state", "state": "{ var[$reference||'.balance'] = $newbalance; response['message'] = 'Withdrawal of ' || $amount || ' bytes from your private pension plan ' || $reference ||'processed.'; response['balance'] = 'The current balance of your pension plan ' || $reference || 'is ' || var[$reference||'.balance']; }" } ] }, { "if": "{timestamp < (var[$reference||'.timestamp'] + var[$reference||'.period'])}", "messages": [ { "app": "payment", "payload": { "outputs": [ { "address": "{var[$reference||'.owner']}", "amount": "{$REIMBURSEMENT}" } ] } }, { "app": "state", "state": "{ response['message'] = 'Withdrawal of ' || $amount || ' bytes from your private pension plan ' || $reference ||' was denied, as your defined expiry date was not yet reached. Expiry date was set to ' || var[$reference||'.timestamp'] || '.'; response['balance'] = 'The current balance of your pension plan ' || $reference || 'is ' || var[$reference||'.balance']; }" } ] } ] } }, { "init": "{ bounce("Enter a data field: owner, deposit or withdraw"); }", "messages": [ { "app": "state", "state": "{ response['usage'] = 'Enter a data field: owner, deposit or withdraw'; }" } ] } ] } } ]
Technical information
Fees:
3,896 bytes
(353 headers, 3543 payload)
Level:1053064
Witnessed level:1053057
Main chain index:1051837
Latest included mc index:1051836
Status:stable/confirmed/final