xiaocongcong888

批量创建以太坊钱包

使用Node批量创建ETH钱包
技术/BlockChain
安装Node
Download | Node.js

初始化项目
mkdir ETHWalletGenerator
cd ETHWalletGenerator
npm init
配置ETH相关的环境
npm install secp256k1
npm install keccak
创建并且编辑ethGenerator.js
\'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);
}
批量生成
node ethGenerator.js

密码:椭圆曲线加密算法
生成公钥和私钥

发表于 2018-08-26 18:26  猴子哥669  阅读(903)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-10-27
  • 2021-10-15
  • 2021-10-19
  • 2021-12-13
  • 2022-02-24
  • 2021-12-19
  • 2021-09-23
猜你喜欢
  • 2021-10-29
  • 2021-10-19
  • 2021-11-21
  • 2021-11-04
  • 2021-11-05
  • 2022-12-23
相关资源
相似解决方案