Skip to content

Instantly share code, notes, and snippets.

@johndpope
Created May 16, 2018 15:45
Show Gist options
  • Save johndpope/a22dcc4a78e7d305e683f6cb887fd1a1 to your computer and use it in GitHub Desktop.
Save johndpope/a22dcc4a78e7d305e683f6cb887fd1a1 to your computer and use it in GitHub Desktop.
npm install bluebird
truffle console --network ganache
const Promise = require('bluebird');
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));
if (typeof web3.eth.getAccountsPromise === 'undefined') { Promise.promisifyAll(web3.eth, { suffix: 'Promise' });}
web3.eth.getBlockNumberPromise().then(_blockNumber => web3.eth.getBlock(_blockNumber)).then(_block => { return "ok" })
let blockNumber = web3.eth.getBlockNumberPromise()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment