1
var test = await web3.eth.getBlockNumber();

I copied this code from the docs but when I call it I get this error:

TypeError: e is not a function

Anyone know what might be causing this?

I'm able to do

userAccountAddress = await web3.eth.accounts[0];

no problem.

Thanks

2

Most web3.js objects allow a callback as the last parameter, as well as returning promises to chain functions.

The error TypeError: e is not a function means it is missing callback function.

In your case await must work out of box, I'm thinking you're use it wrong, here is an example from documentation getBlockNumber():

web3.eth.getBlockNumber().then(console.log);
> 2744

If you still want use await you must use it right, with async keyword.

(async ()=> { await web3.eth.getBlockNumber(console.log) })()
> 2744

Looks ugly ya? That's javascript my friend.

Tip: If you want the blocknumber you can use web3.eth.blockNumber.

  • 1
    Please make the tip larger, it works great in truffle develop! – Paul Razvan Berg Aug 19 '18 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.