I have been developing a smart contract (ERC-721 compliant) which needs to be populated with lots of various pieces of data.
Approximately 300 ERC721 tokens need to be minted inside the contract at the point of deployment.
I have a json data structure which details all the required initial tokens and their data attributes to be minted inside the contract.
I have currently created a new migrations script e.g.
4_populated_tokens.js which truffle run when deploying to each network.
This always succeeds locally with ganache but when running against any testnet I this always seems to eventually fail, occasionally with 80% or more of the content, usually for the following reason:
Error encountered, bailing. Network state unknown. Review successful transactions manually.
I have tried adjusting the migration with some success by doing the following:
- Only minting a single token at once i.e. serially instead of firing lots of inserts at once
- Increasing the gas per transaction
There has been some success with this.
My question :
Is it correct to use truffle migrate to populate such large amounts of data, if not what is the preferred solution?
Do other people also have this problem using truffle to run in large amounts of data as part of a migration?
All help appreciated, thanks.