nash-io / neo-ico-template

An ICO Template for NEO projects
GNU General Public License v3.0
117 stars 56 forks source link

Trigger transfer event in deploy #29

Open arrix opened 6 years ago

arrix commented 6 years ago

https://github.com/neo-project/proposals/blob/master/nep-5.mediawiki

A token contract which creates new tokens MUST trigger a transfer event with the from address set to null when tokens are created.

Blockchain explorers like neoscan need the event to keep track of balance correctly.


if not Get(ctx, 'initialized'):
        # do deploy logic
        Put(ctx, 'initialized', 1)
        Put(ctx, TOKEN_OWNER, TOKEN_INITIAL_AMOUNT)

        OnTransfer(None, TOKEN_OWNER, TOKEN_INITIAL_AMOUNT)

        return add_to_circulation(ctx, TOKEN_INITIAL_AMOUNT)```