其他分享
首页 > 其他分享> > 如何生成钱包

如何生成钱包

作者:互联网

源码

https://github.com/chaincc/just_tools

 

const { ethers } = require("ethers");

function main() {  
    newWallet()
}

main();

async function newWallet() {
    var privateKey = ethers.utils.randomBytes(32);
    var wallet = new ethers.Wallet(privateKey);

    let keyNumber = ethers.BigNumber.from(privateKey);
    if (keyNumber._hex.length != 66){
        console.log("key length fail,请重新执行")
        return
    }

    console.log("账号地址:  "+wallet.address);
    console.log("账号私钥:  "+keyNumber._hex);

}

 

标签:console,log,privateKey,生成,如何,keyNumber,钱包,newWallet,ethers
来源: https://www.cnblogs.com/ziyunlong/p/16574358.html