0

My goal is to deliver the tokens only at the end of the crowd sale. I have seen the below code which can deliver the tokens in a batch.

Questions

  1. Will this work even when there is a million _to address ?
  2. Apart from the below snippet, Is there any better way to do this ?

    /**
     * @dev Function to batch mint tokens
     * @param _to An array of addresses that will receive the minted tokens.
     * @param _amount An array with the amounts of tokens each address will get     minted.
     * @return A boolean that indicates whether the operation was successful.
     */
    function batchMint(address[] _to, uint256[] _amount) external
    canMint
    returns (bool) {
        require(_to.length == _amount.length);
        for (uint i = 0; i < _to.length; i++) {
            require(_to[i] != address(0));
            require(mint(_to[i], _amount[i]));
        }
        return true;
    }
    
1

If you just want to mint the tokens, and not knowing the rest of the code, this is the best approach i can think of. You should take into consideration a few things, however.

First, time constraints. It does not check if the crowdsale has ended and, as far as I can see, can be called at any time. If you want to make it available only for a short period of time after crowdsale has ended, you should first check that that has happened, and then, after using it, set some variable so it can never be used again.

Second, gas limits. You will not be able to handle an arbitrary amount of recipients. Most likely you will only be able to handle about 800 or less, depending on your implementation. It's likely that you will need to do multiple transactions, and if you use some mechanism to avoid to have this function called at any time, you should have to take this into consideration.

  • ok is there is any other better way ? – iappmaker Dec 7 '18 at 2:06
  • Is there is any script to do this 800 by 800 – iappmaker Dec 7 '18 at 2:11
  • 800 was an example, it depends on your exact implementation. Using this script multiple times would work, but again, it depends on what exactly you want to achieve, just be aware of the gas limit per block. – Hari GTT Psicolabis Dec 7 '18 at 17:07
  • any sample / code snippet please ? – iappmaker Dec 11 '18 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.