# 用代码生成ETH钱包(新手教程) **Published by:** [皱水](https://paragraph.com/@zhoushui/) **Published on:** 2022-05-16 **URL:** https://paragraph.com/@zhoushui/eth ## Content 新手除了使用 Metamask、Rainbow 等钱包来生成 ETH 钱包地址外,也可以尝试下面的方法,来利用 ethers.js 生成以太坊钱包,可以本地断网运行,绝对安全。第一步在自己的电脑上,安装node环境,以mac电脑为例,在终端中输入:如果提示 “commond not found: brew” 的话,可以在终端中输入下方代码,先安装 brew 命令:/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" 第二步安装ethers模块,方便后面来引入ethers.jsnpm install --save ethers 第三步将下面代码,另存为:wallet.js 文件 //引入ethers.js var ethers = require('ethers'); //拿到生成的钱包信息 var wallet = ethers.Wallet.createRandom(); //获取助记词 var mnemonic = wallet.mnemonic; console.log("钱包助记词:",mnemonic) //获取path var path = wallet.path; console.log("钱包path:",path) //获取钱包的私钥 var privateKey = wallet.privateKey; console.log("钱包私钥:",privateKey) //获取钱包地址 var address = wallet.address; console.log("钱包地址:",address) 然后运行node wallet.js 最后就可以看到生成的ETH钱包了ETH Wallet Generate如果是windows电脑的话,方法类似,可以先从 nodejs 官网,下载并安装 windows 版本的node 安装包。 https://nodejs.org/en/download/ 然后重复上面的第二步和第三步就可以了。 ## Publication Information - [皱水](https://paragraph.com/@zhoushui/): Publication homepage - [All Posts](https://paragraph.com/@zhoushui/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@zhoushui): Subscribe to updates