neo-ico-template icon indicating copy to clipboard operation
neo-ico-template copied to clipboard

Trigger transfer event in deploy

Open arrix opened this issue 6 years ago • 0 comments

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)```

arrix avatar Aug 02 '18 12:08 arrix