Last active
February 3, 2025 09:53
-
-
Save copostic/376ffbf0e5f4c0e7bde81dcd52487866 to your computer and use it in GitHub Desktop.
Web3 Wallet generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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