Unit ID
xyCbufG+an2GngwZaxBEGBmy1lUv9HdC74ZUd6OamTs=
Received
21.08.2019 00:36:02
Confirmation delay (full node)
4 minutes 6 seconds
Confirmation delay (light node)
6 minutes 23 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ // 1 - increment me if already posted to DAG $asset = var['asset']; $founder = var['founder']; $minutes_from_epoch = timestamp / 60; $hours_from_epoch = $minutes_from_epoch / 60; $days_from_epoch = $hours_from_epoch / 24; $weeks_from_epoch = $days_from_epoch / 7; $periods_from_epoch = floor($hours_from_epoch); // choose weeks, days, hours or minutes here $current_period = $periods_from_epoch - var['start'] + 1; $max_claim_per_period = 1e6; $max_crowdsale_periods = 720; }", "messages": { "cases": [ { "if": "{!$asset}", "messages": [ { "app": "asset", "payload": { "is_private": false, "is_transferrable": true, "auto_destroy": false, "fixed_denominations": false, "issued_by_definer_only": true, "cosigned_by_definer": false, "spender_attested": false } }, { "app": "state", "state": "{ // start the new crowdsale with new asset var['asset'] = response_unit; var['founder'] = trigger.address; var['start'] = $periods_from_epoch; response['message'] = 'Crowdsale started'; }" } ] }, { "if": "{trigger.address == $founder}", "init": "{ // founder withdrawing $withdraw_asset = trigger.data.withdraw_asset ? trigger.data.withdraw_asset : 'base'; if (!balance[$withdraw_asset]) bounce('Nothing to withdraw.'); }", "messages": [ { "app": "payment", "payload": { "asset": "{$withdraw_asset}", "outputs": [ { "address": "{$founder}" } ] } } ] }, { "if": "{trigger.data.claim_period}", "init": "{ // investor claiming if (trigger.data.claim_period >= $current_period) bounce('Claiming is only possible for previous periods.'); $claim_address = trigger.data.claim_address ? trigger.data.claim_address : trigger.address; $investor_claim_period = var['investor_' || $claim_address || '_' || trigger.data.claim_period]; if (!$investor_claim_period) bounce('Investor didn\'t invest on that period or already claimed that period.'); $total_raised_on_period = var['total_raised_' || trigger.data.claim_period] + $amount; $invesor_share = $investor_claim_period / $total_raised_on_period; $claim_amount = floor($invesor_share * $max_claim_per_period); }", "messages": [ { "app": "payment", "payload": { "asset": "{$asset}", "outputs": [ { "address": "{$claim_address}", "amount": "{$claim_amount}" } ] } }, { "app": "state", "state": "{ var['investor_' || $claim_address || '_' || trigger.data.claim_period] = false; response['message'] = 'Investor claimed'; }" } ] }, { "init": "{ // investing in current period if ($current_period > $max_crowdsale_periods) bounce('Crowdsale is over.'); $investor_on_period = var['investor_' || trigger.address || '_' || $current_period]; $amount = trigger.output[[asset=base]]; $total_raised_on_period = var['total_raised_' || $current_period] + $amount; $total_investor_on_period = $investor_on_period + $amount; }", "messages": [ { "app": "state", "state": "{ var['total_raised_' || $current_period] = $total_raised_on_period; var['investor_' || trigger.address || '_' || $current_period] = $total_investor_on_period; response['message'] = 'Use claim_period(' || $current_period || ') and claim_address(' || trigger.address || ') in data.'; }" } ] } ] } } ]
Technical information
Fees:
3,270 bytes
(353 headers, 2917 payload)
Level:1015994
Witnessed level:1015987
Main chain index:1014812
Latest included mc index:1014811
Status:stable/confirmed/final