Skip to content

Instantly share code, notes, and snippets.

@BCEvanFang
Created November 1, 2018 09:55
Show Gist options
  • Select an option

  • Save BCEvanFang/396b6bd303f41041ef1740bf183fc895 to your computer and use it in GitHub Desktop.

Select an option

Save BCEvanFang/396b6bd303f41041ef1740bf183fc895 to your computer and use it in GitHub Desktop.
web3 example
/// npm install web3 --save
var Web3 = require("web3")
var web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:7545"))
web3.eth.getAccounts().then((accounts) => {
console.log("Accounts:");
console.log(accounts);
}).catch((error) => {
console.error(error);
});
web3.eth.getCoinbase().then((coinbase) => {
console.log("Coinbase:");
console.log(coinbase);
}).catch((error) => {
console.error(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment