Unit ID
4RJ9RzxyJaOwc3T3/CCfXhkGGbjWCX9h2+G0IdvD5W4=
Received
14.08.2019 17:23:36
Confirmation delay (full node)
4 minutes 33 seconds
Confirmation delay (light node)
5 minutes 35 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $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 = 500; }", "messages": { "cases": [ { "if": "{!$asset}", "messages": [ { "app": "asset", "payload": { "is_private": false, "is_transferrable": true, "auto_destroy": true, "fixed_denominations": false, "issued_by_definer_only": true, "cosigned_by_definer": false, "spender_attested": false } }, { "app": "state", "state": "{ var['asset'] = response_unit; var['founder'] = trigger.address; var['start'] = $periods_from_epoch; response['message'] = 'Crowdsale started'; }" } ] }, { "if": "{$asset AND trigger.address == $founder}", "init": "{ $founder_claim_amount = balance[base]-1000; }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$founder}", "amount": "{$founder_claim_amount}" } ] } }, { "app": "state", "state": "{ response['message'] = 'Founder claimed'; }" } ] }, { "if": "{$asset AND trigger.address != $founder AND trigger.data.claim_period}", "init": "{ 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("You didn\'t invest on that period."); if ($investor_claim_period < 0) bounce("You have 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] = -1; response['message'] = 'Investor claimed'; }" } ] }, { "if": "{$asset AND trigger.address != $founder AND !trigger.data.claim_period AND $current_period <= $max_crowdsale_periods}", "init": "{ $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,198 bytes
(353 headers, 2845 payload)
Level:998767
Witnessed level:998760
Main chain index:997585
Latest included mc index:997584
Status:stable/confirmed/final