使用Node批量创建ETH钱包 发表于 2018-04-24 15:28:00 | 更新于 2018-07-16 21:20:13 | 分类于 blockchain 使用Node批量创建ETH钱包安装NodeDownload | Node.js 初始化项目123mkdir ETHWalletGeneratorcd ETHWalletGeneratornpm init 配置ETH相关的环境12npm install secp256k1npm install keccak 创建并且编辑ethGenerator.js123456789101112131415161718192021222324252627282930313233'use strict';console.log('Generator Start..............');const num = 5;const secp256k1 = require("secp256k1/elliptic");const createKeccakHash = require("keccak");const crypto = require('crypto');// 地址转换function toChecksumAddress(address) { address = address.toLowerCase().replace('0x', ''); var hash = createKeccakHash('keccak256').update(address).digest('hex'); var ret = '0x'; for (var i = 0; i < address.length; i++) { if (parseInt(hash[i], 16) >= 8) { ret += address[i].toUpperCase(); } else { ret += address[i]; } } return ret;}for (var i = 0; i < num; i++) { // 生成私钥 const privateKey = crypto.randomBytes(32); // 生成公钥 const publicKey = secp256k1.publicKeyCreate(privateKey, false).slice(1); // 生成地址 const address = createKeccakHash("keccak256").update(publicKey).digest().slice(-20); const normAddress = toChecksumAddress(address.toString('hex')); // 查看结果 console.log(privateKey.toString('hex')); console.log(normAddress);} 批量生成1node ethGenerator.js 本文作者: 熊伟 本文链接: http://tedxiong.com/2018-04-24-eth_wallet_generator/ 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!