Skip to content

Instantly share code, notes, and snippets.

@copostic
Last active February 3, 2025 09:53
Show Gist options
  • Save copostic/376ffbf0e5f4c0e7bde81dcd52487866 to your computer and use it in GitHub Desktop.
Save copostic/376ffbf0e5f4c0e7bde81dcd52487866 to your computer and use it in GitHub Desktop.
Web3 Wallet generator
{
"name": "wallet-generator",
"version": "1.0.0",
"description": "Package to generate n ETH wallets",
"main": "wallet_generator.js",
"type": "module",
"scripts": {
"dev": "node wallet_generator.js"
},
"license": "ISC",
"dependencies": {
"web3": "^1.8.1",
"lowdb": "^5.0.5"
}
}
import {Low} from 'lowdb';
import {JSONFile} from "lowdb/node";
import Web3 from 'web3';
const INFURA_TOKEN = ''; // TODO Replace this with the token of your infura account
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/v3/${INFURA_TOKEN}'))
const adapter = new JSONFile('keysDB.json')
const db = new Low(adapter);
db.data ||= { keys: [] }
async function createWallets(n) {
for (let i = 0; i < n; i++) {
console.log(`Wallet #${i + 1} generated`)
const tempWallet = web3.eth.accounts.create()
console.log(`Address: ${tempWallet.address}\n`)
db.data.keys.push({
id: i,
address: tempWallet.address,
privKey: tempWallet.privateKey
});
await db.write();
}
}
createWallets(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment