Last active
August 13, 2024 00:28
-
-
Save taarushv/1a649169ed308dcc3077ccf8bf231d49 to your computer and use it in GitHub Desktop.
Script to generate 'n' ethereum wallets (address + private key) and store it in a JSON. keysDB.json is the example output.
This file contains hidden or 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
// Init web3 and configure to a node (alternatively to infura/ganache-cli) | |
var Web3 = require('web3') | |
var web3 = new Web3('http://127.0.0.1:8545') | |
// Setup lowdb to store | |
const low = require('lowdb') | |
const FileSync = require('lowdb/adapters/FileSync') | |
const adapter = new FileSync('keysDB.json') | |
const db = low(adapter) | |
db.defaults({ keys: [], count: 0 }).write() | |
function createWallets(n){ | |
for(i=0;i<n;i++){ | |
console.log(`Wallet #${i+1} generated`) | |
// Create wallet | |
const tempWallet = web3.eth.accounts.create() | |
console.log(`Address: ${tempWallet.address}\n`) | |
// Add keys to JSON | |
db.get('keys').push({id:db.get('count').value()+1,address:tempWallet.address, privKey:tempWallet.privateKey}).write() | |
db.update('count', n => n + 1).write() | |
} | |
} | |
createWallets(10) |
This file contains hidden or 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
{ | |
"keys": [ | |
{ | |
"id": 1, | |
"address": "0xD9D7e52b27CdDC12A792E621940DAB6a5EDFF3a5", | |
"privKey": "0x76430d2f715a2b43eff52684089570d29b53c5e7248f0e6267b83df143f0b10b" | |
}, | |
{ | |
"id": 2, | |
"address": "0xB6BAd4A3F62549c35a88b6088c2c32ea1a16324B", | |
"privKey": "0xe3ee3f107efecde084f4116586934bd23df90b1e6bb50aff2e98dae558091a82" | |
}, | |
{ | |
"id": 3, | |
"address": "0x12cFe887ee75F7adD1332FfAfe32746C5602f22e", | |
"privKey": "0x0585ca813150ac5d968ce9b14b94eb01c81e46c208e437067c40fe60ccbf9f3e" | |
}, | |
{ | |
"id": 4, | |
"address": "0x1F08aEa7d33011Fb7e8097C5FB0aFfc0d0f588A4", | |
"privKey": "0x1ed841b9c190941850036b3019c87355937529e0dade073900680bc01ef11f93" | |
}, | |
{ | |
"id": 5, | |
"address": "0x3875d66A26Fa374E7a1BD1A1c3d8b145C428BA62", | |
"privKey": "0x45b0278d08d84f23150b1e9f8d6df8ba4c0a746fb4fd2fc4616d35d01b9851d8" | |
}, | |
{ | |
"id": 6, | |
"address": "0x2Ae69c9619f53f0E9eDFe5699D7f43523B638554", | |
"privKey": "0xdcfaf21dfbb2fd6a8ca08fe17afc282e2058ee2a2f557c6bcfcee72556cb3dfc" | |
}, | |
{ | |
"id": 7, | |
"address": "0xEbeF26030a53FCbD17723a640Ce04f30e815df44", | |
"privKey": "0xfde583889268cf59df96993a1a0f78c76e15df8b53732fb4222e732fac8f6712" | |
}, | |
{ | |
"id": 8, | |
"address": "0x358CcE6cE79D30a32A8c22bCC0cdD85C60997a47", | |
"privKey": "0x5a7aa67ce8886b4e61b86ce317dbcd22a910c2da00c89ecc6357343b9ff216de" | |
}, | |
{ | |
"id": 9, | |
"address": "0xd948A3475fbF543D2Afe5bCc38cb1e097C8e864B", | |
"privKey": "0xb522c546b91766e601afff61075e674240cfa8141b3426e48af922437ee40fc8" | |
}, | |
{ | |
"id": 10, | |
"address": "0xA1F384170d8708dA8Cef3cB810879A0A9159dF1f", | |
"privKey": "0x0a3d200663042e873d1765250365d09065bf62ac837774ce51cb0a1f72f99c1b" | |
} | |
], | |
"count": 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i want find private key