Truffle: web3.currentProvider is undefined

Created on 1 Jan 2019  路  3Comments  路  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

During test run, web3.currentProvider is undefined.

Steps to Reproduce

Just console.log(web3.currentProvider)

Expected Behavior

Expected to have a value other than undefined.

Actual Results

I am trying to execute

    await web3.currentProvider.send({
      jsonrpc: "2.0",
      method: "evm_increaseTime",
      params: 10,
      id: 0
    });

To increase evm time inside the test. But because of currentProvider is undefined, I can't.
Result:

TypeError: Cannot read property 'send' of undefined

Environment

  • Operating System: Ubuntu 18.04.1
  • Ethereum client: Ganache CLI v6.2.5 (ganache-core: 2.3.3)
  • Truffle version (truffle version): 5.0.0
  • node version (node --version): 10.14.2
  • npm version (npm --version): 6.5.0

Most helpful comment

@CruzMolina Yeah, I figured out sendAsync doesn't exist anymore but there is send. We can close the issue.

All 3 comments

Hey @ferittuncer, thanks for reporting this!

Can you provide a repo link? I notice in the gitter you were trying to use sendAsync (which shouldn't work anymore in v5 since we upgraded to web3 1.0).

@CruzMolina Yeah, I figured out sendAsync doesn't exist anymore but there is send. We can close the issue.

import Web3 from 'web3';
const web3=new Web3(window.web3.currentProvider); //i got error here cannot read property of undefined currentProvider
const address='0x23BD82c94d40daeF4B013316690732C050D36028';

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rotcivegaf picture rotcivegaf  路  3Comments

jleeh picture jleeh  路  3Comments

ysfAskri picture ysfAskri  路  4Comments

timothywangdev picture timothywangdev  路  3Comments

TOMOAKI12345 picture TOMOAKI12345  路  3Comments