Web3.js以太坊开发(一)Win10系统下的安装与配置
1.安装node.js与git工具(exe安装即可)
2.在cmd中通过 npm cache verify 清理下缓存,在进行安装。
3.使用npm install [email protected]^0.20.0安装web3.js
4.安装testrpc(区块链的测试节点):npm install -g ethereumjs-testrpc
5.在 cmd 执行 testrpc,看到下图所示的账户和私钥
6.如下编写test.js测试文件
var Web3 = require('web3')
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
console.log(web3.eth.accounts)
重开一个cmd,跳转到该文件目录下,用node test.js指令运行该文件
7.运行后的结果如下图:
说明已经从测试的testrpc节点中获得了accounts账户信息