1:以太坊Dapp开发i环境ganache的使用
1:ganache安装参考:https://github.com/trufflesuite/ganache
2:安装完成执行ganache 出现下图,代表成功并启动了,ganache启动私链默认会创建10个账户并有1000个eth

3:用web3js 连接访问ganache的私链安装web3
npm install web3 -save
4:创建一个js文件 如test.js
const Web3 = require("web3");const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));console.log(web3.version);
web3.eth.getAccounts().then(console.log);
5: 在test.js目录执行node test.js,出现如下结果,打印了版本和打印了账户,代表成功连接到私链
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
