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
1,560 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,220 points

Related Questions In Blockchain

0 votes
0 answers

Cannot read property 'curve' of undefined, while running hyperledger fabric project.

Cannot read property 'curve' of undefined ...READ MORE

Jan 30, 2019 in Blockchain by shraddha
1,598 views
0 votes
0 answers

Azure Blockchain , Cannot read property 'uri' of undefined

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

Apr 4, 2022 in Blockchain by Rahul
• 9,680 points
416 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
736 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,740 points
754 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
1,922 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
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 2,475 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,220 points
1,932 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,220 points
3,131 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP