airdrop and lock tokens for specific time

502 views Asked by At

I want to airdrop and presale my won token so in the next step I want to lock them until my IDO data come and unlock in this time 30% of user wallet balances and next month 50 % what is the best way to do this

1

There are 1 answers

1
invisiblecat On

If you want your token to be sent to users when certain date comes automatically without backend or any users or you doing the transactions, it is not possible. Blockchain operations cannot be executed without calling a transaction using scripts by user or backend.

You can write the following airdrop contract to achieve desired result:

Users send stable coins to your airdrop contract. Addresses of these users should be stored in some place. You can store addresses and amounts of token buyers automatically (in arrays on the blockchain - address[] buyers, uint256[] amounts).

If you want users to click on button on website to receive available amount of tokens, your airdrop contract should have a method to send right amount of your token to caller if the caller sent stable coins before. This method should check, if msg.sender is in buyers (check in array can be expensive, you can create a buyers map only for this check) and if airdrop date has come (you can save timestamps in seconds in some array and check if any date has come via comparison with block.timestamp). If both requirements are met, contract sends tokens from your balance (transferFrom) or from its balance (transfer) following the exchange rate.

If you want send the transaction by yourself to give all tokens to buyers, you can make the method, which can be called only by you (Ownable will be very helpful). Inside this method, contract goes through buyers array and send amount[buyerIndex]*exchangeRate to each of them. This method doesn't require users to click on any buttons, but can be very expensive in gas and hence for you.