for (let i = 0; i < 100; i++) { const node = HDNode.derivePath(`m/44'/60'/0'/0/${i}`) data.accounts.push({ pub: node.address, pri: node.privateKey, }) }
if (!fs.existsSync("accounts.json")) { fs.writeFile("./accounts.json", JSON.stringify(data, 0, 4), (err) => { if (err) console.error(err) else { console.log("🤩 100 accounts generated successfully!") } }) } else { console.log( "You've already generated 100 accounts, are you sure to generate a new one?\nIf you want please delete accounts.json, and remember to backup the mnemonic first⚠️!!!" ) }
After installing the required libraries, run it directly, and the result is kept in the csv file. Overall It is not as elegant as the generated wallet code of node.js. The code of node.js is also more efficient, and at the same time, it can be saved directly with auxiliary words. This is very convenient for users.
Notes
I need to emphasize the storage of mnemonic and private key. Never store them on the network, write them down and hide them. If it is a large number of private keys, you can encrypt the storage, you can also split the separate storage. Never put the complete private key, mnemonic on the internet. Too many of them are stolen from places like Netflix, Cloud Notes, iCloud, and so on.
In addition to storage, we usually best to use the code operation, copy the private key, mnemonic words do not complete copy, the remaining part of the hand-typed up, to develop such a habit.
Must must develop the above two good habits, as long as the principal is not lost can always make money, the principal is gone and then earn can be difficult!