How do you mint a large amount of ERC721 Tokens in a Solidity constructor?

I am using the below call to Open Zeppelin code. I
am getting the error when I migrate the contract.

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: VM Exception while processing transaction: out of gas

Other error I get sometimes is the below as well:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: VM Exception while processing transaction: invalid opcode

The below code works if I change the for loop variable to i < 10 and take away the line: purchasers[i]=0x88e4668f3CC1bBA40f3D50010F50EAd17Ce290Ce;

address[] public purchasers;


constructor() public
{  

  for(uint i = 0; i < 50; i++)
  {
      purchasers[i]=0x88e4668f3CC1bBA40f3D50010F50EAd17Ce290Ce;
      mintUniqueTokenTo(0x88e4668f3CC1bBA40f3D50010F50EAd17Ce290Ce, i);
      createEntity(i,"Michael","images/scottish-terrier.jpeg",1,true);

   }

}

function mintUniqueTokenTo(address _to, uint256 _tokenId) public
{
    super._mint(_to, _tokenId);
}

Leave a Reply

Your email address will not be published. Required fields are marked *