0

"web3": "^1.0.0-beta.37"

"web3": "^1.0.0-beta.55"

import {Miner} from 'web3-eth-miner';

then

  const options = {
        defaultAccount: "0x78dB3e2129D58685444989dD9682DDDC70dd3C82",
        defaultBlock: 'latest',
        defaultGas: 1,
        defaultGasPrice: 0,
        transactionBlockTimeout: 50,
        transactionConfirmationBlocks: 24,
        transactionPollingTimeout: 480,
      }
      const miner = new Miner("http://127.0.0.1:9545", null,options);
      console.log(miner); miner.start(2);

miner.start() says that it is not a function()... ref : https://web3js.readthedocs.io/en/1.0/web3-eth-miner.html

  • You're doing console.log(miner). Sure you can elaborate on the output of that line! – goodvibration Jun 5 at 13:30
  • try miner.startMining("0x2") – Majd TL Jun 5 at 15:04
  • @MajdTL miner.startMining("0x2") gives error TypeError: miner.startMining is not a function – Arjun Trivedi Jun 5 at 15:43
  • @goodvibration console.log(miner) returns Proxy {providerResolver: ProviderResolver, givenProvider: Proxy, _currentProvider: HttpProvider, _defaultAccount: "0x78dB3e2129D58685444989dD9682DDDC70dd3C82", _defaultBlock: "latest", …} [[Handler]] : Object [[Target]] : Miner [[IsRevoked]] : false – Arjun Trivedi Jun 5 at 15:44
  • And what does npm ls web3 tells you when you run it from the same place you run your script? – goodvibration Jun 5 at 15:58
0

This will not work with web3@1.0.0-beta.37, cause web3-eth-miner has been added lately, update web3 to 1.0.0-beta.55

old version

enter image description here

new version

enter image description here

  • I've tried to upgrading the "web3": "^1.0.0-beta.55", still same error that TypeError: miner.startMining is not a function – Arjun Trivedi Jun 6 at 4:39
  • check the version of web3 js in your package.json, and delete nodes modules and package.lock and then try npm install and miner.start(2) ? – Majd TL Jun 6 at 7:34
  • that didn't worked. web3-eth-miner is an sub module which need to gets installed additionally. – Arjun Trivedi Jun 6 at 11:39
  • modules and methods are changed and new startMining method doesn't work as well. ref :github.com/ethereum/web3.js/blob/1.0/docs/web3-eth-miner.rst – Arjun Trivedi Jun 6 at 11:42

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.