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, 2019 in Blockchain by Karuna
657 views

1 answer to this question.

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, 2019 by Omkar
• 69,190 points

Related Questions In Blockchain

0 votes
0 answers
0 votes
0 answers

Azure Blockchain , Cannot read property 'uri' of undefined

I am starting with Azure Blockchain. When ...READ MORE

Apr 4 in Blockchain by Rahul
• 8,980 points
11 views
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
• 17,100 points
303 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
• 26,720 points
253 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
922 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, 2019 in Blockchain by saeedi
• 120 points

edited Mar 6, 2019 by Omkar 1,625 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
• 69,190 points
1,265 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
• 69,190 points
2,241 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP