打印 ganache环境的账户列表
const localhost = "http://127.0.0.1:7545"; const {Web3} = require("web3"); const web3 = new Web3(new Web3.providers.HttpProvider(localhost));web3.eth.getAccounts().then(function (result) {console.log("账户列表地址:");console.log(result); }).catch(function (error) {console.error(error); });
运行
发送eth
let amountToSend = web3.utils.toWei('1', 'ether');web3.eth.sendTransaction({from: '0xA61Cc9999B16a1F58E3ABBEDF3392b67dAd896fd',to: '0xFD3a265399C04b06C9FBBbc28634dA0cB6215736', value:amountToSend,gas: '1000000',gasPrice:1000000000 });
运行后