Cannot read property 'getBlock' of undefined

0 votes

I am facing issues with truffle test. When I run truffle test, I am getting the following error:

TypeError: Cannot read property ' getBlock ' of undefined.

But it runs fine on console.

Jan 29 in Blockchain by Karuna
36 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

getBlock is used by web3 and to use it, you have to mention the web3 provider in your code. Like this:

if (typeof web3 !== 'undefined') {
    // Use Mist/MetaMask's provider
    web3 = new Web3(web3.currentProvider);
answered Jan 29 by Omkar
• 65,840 points

Related Questions In Blockchain

0 votes
0 answers
0 votes
1 answer

How can i read headers of blockchain in multichain?

You could use a recent feature known ...READ MORE

answered Mar 26, 2018 in Blockchain by Perry
• 16,450 points
26 views
0 votes
1 answer

How to get property of non object in Coinbase API

First, your sendMoney() call is stored into ...READ MORE

answered Aug 31, 2018 in Blockchain by digger
• 27,620 points
21 views
+1 vote
1 answer

Security Properties of Hash Functions

The difference is indeed subtle. I understood ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,050 points
196 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
63 views
0 votes
1 answer
0 votes
1 answer
0 votes
0 answers

Error: Unexpected token o in JSON at position 1

I have been working with Interacting a ...READ MORE

Mar 6 in Blockchain by saeedi
• 120 points

edited Mar 6 by Omkar 112 views
0 votes
1 answer

Ethereum Node Connection: TypeError: Cannot read property 'version' of undefined

In the code that you are using ...READ MORE

answered Oct 24, 2018 in Blockchain by Omkar
• 65,840 points
78 views
0 votes
1 answer

Getting Invalid number of parameters for “undefined” when deploying smart contract

Try something like this for contracts that ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 65,840 points
294 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.