My project uses the react truffle box, and I use the getWeb3 method that comes with it.

After calling that method, I store the web3 object on Redux's state tree via the action creator storeWeb3.

getWeb3 .then(results => { storeWeb3(results.web3); });

This works fine when deploying to the ganache local blockchain (localhost:8545), but breaks when I deploy to the Rinkeby testnet and turn Metamask on.

Here're the error logs:

Uncaught Error: The MetaMask Web3 object does not support synchronous methods like eth_mining without a callback parameter. See https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async---think-of-metamask-as-a-light-client for details.
    at MetamaskInpageProvider.send (inpage.js:14)
    at RequestManager../node_modules/web3/lib/web3/requestmanager.js.RequestManager.send (requestmanager.js:58)
    at Eth.get [as mining] (property.js:107)
    at derez (<anonymous>:1:66285)
    at derez (<anonymous>:1:66278)
    at derez (<anonymous>:1:66278)
    at derez (<anonymous>:1:66278)
    at derez (<anonymous>:1:66278)
    at Object.decycle (<anonymous>:1:66315)
    at Object.e.stringify (<anonymous>:1:19676)
    at tryCatchStringify (<anonymous>:1:68827)
    at stringify (<anonymous>:1:68935)
    at toContentScript (<anonymous>:1:70219)
    at relay (<anonymous>:1:23214)
    at <anonymous>:1:26299
    at invokeFunc (<anonymous>:1:29789)
    at leadingEdge (<anonymous>:1:29866)
    at debounced (<anonymous>:1:30443)
    at Object.onMessage (<anonymous>:1:24470)
    at <anonymous>:1:70941
    at Array.forEach (<anonymous>)
    at handleMessages (<anonymous>:1:70876) MetamaskInpageProvider.send @ inpage.js:14 ./node_modules/web3/lib/web3/requestmanager.js.RequestManager.send @ requestmanager.js:58 get @ property.js:107 derez @ VM26460:1 derez @ VM26460:1 derez @ VM26460:1 derez @ VM26460:1 derez @ VM26460:1 decycle @ VM26460:1 e.stringify @ VM26460:1 tryCatchStringify @ VM26460:1 stringify @ VM26460:1 toContentScript @ VM26460:1 relay @ VM26460:1 (anonymous) @ VM26460:1 invokeFunc @ VM26460:1 leadingEdge @ VM26460:1 debounced @ VM26460:1 onMessage @ VM26460:1 (anonymous) @ VM26460:1 handleMessages @ VM26460:1 postMessage (async) (anonymous) @ content.bundle.js:1 EventImpl.dispatchToListener @ VM26487 extensions::event_bindings:403 publicClassPrototype.(anonymous function) @ VM26493 extensions::utils:138 EventImpl.dispatch_ @ VM26487 extensions::event_bindings:387 EventImpl.dispatch @ VM26487 extensions::event_bindings:409 publicClassPrototype.(anonymous function) @ VM26493 extensions::utils:138 dispatchOnMessage @ VM26494 extensions::messaging:392 localhost/:1

Denying load of chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/sourcemaps/inpage.js.map. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension. index.js:885

GET chrome-extension://invalid/ net::ERR_FAILED
  • The problem must be when you actually use Web3 and no how you set it up. I recommend you to read the section here about asynchronous call in Web3 – Greg Jeanmart Apr 24 '18 at 8:38
  • Thanks for the help @GregJeanmart. This is the only Web3 call I'm making, just to get the object from the module. And if I tweak the syntax to pass a callback, I still get an error ` getWeb3((error, result) => { if (!error) console.log(result); else console.error(error); });` Uncaught TypeError: Object(...) is not a function at Object.getWeb (blockchain.js:22) at new Welcome (Welcome.js:33) at ReactCompositeComponent.js:292 at measureLifeCyclePerf (ReactCompositeComponent.js:73) Do you have any idea what may be causing this? – Pedro Nobre de Figueiredo Apr 26 '18 at 1:51

Your Answer

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

Browse other questions tagged or ask your own question.