Created
November 1, 2018 09:55
-
-
Save BCEvanFang/396b6bd303f41041ef1740bf183fc895 to your computer and use it in GitHub Desktop.
web3 example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// 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