- 图形界面版本 : https://trufflesuite.com/ganache/
- 命令行版本 :
// 安装ganache-cli
npm install -g ganache-cli
// 在内存中运行ganache
ganache-cli
// 新建一个测试用的文件夹
mkdir test
// 安装web3js库
npm isntall web3 --save
// test.js
var Web3 = require('web3')
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
console.log(web3.version)
web3.eth.getAccounts().then(console.log)
// 以下为打印结果
1.7.4
[
'0xAe06fAC68fD0B60DD271683fa38Ad80E0a91F334',
'0x7270B09BaEc7d23563c03cFee60082b8d203064a',
'0xA6cC47151Db0FA06d8573197261b97EA9DB18E0d',
'0x2Bc58E233c7CE5F429bD1a6eb4a949da9efBFDaC',
'0x405054b3B795F81FEd0c5c3D3c06c687139d6982',
'0x7246537798Db37D7761F87e128c186D35d17490F',
'0x153880dA793B96F654B179Be651cd6F43eA9f3ac',
'0xb27bAD88D87A39B17D9769d94b852a290df9994a',
'0x0a041581475a69E661AF19757186B71156E95A80',
'0xd7D0125e4Cb61398392B51665aE0Ce9906F998b5'
]
Q.E.D.