I have connect to my rpc geth via web3 successfully, but I can't connect web3-eth-miner to my server. Here is my code

I started my rpc server as

geth --datadir ./tolotolo  --rpc --rpcapi="db,eth,net,web3,personal,web3,miner" --rpcport 5200 --rpcaddr --rpccorsdomain "" --allow-insecure-unlock

var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider(config.ethUrl));
const { Miner } = require("web3-eth-miner");
const options = {
    defaultAccount: config.adminAccount,
    defaultBlock: 'latest',
    defaultGas: 1,
    defaultGasPrice: 0,
    transactionBlockTimeout: 50,
    transactionConfirmationBlocks: 24,
    transactionPollingTimeout: 480,
    .then(() => {
        console.log('web3 is connected'); // Here web3 is connected
        const miner = new Miner(new web3.providers.HttpProvider(config.ethUrl), null, options);
        // miner.startMining(1).then(console.log);
    .catch(e => console.log(e));

Miner console shows

givenProvider: null,
  _currentProvider: CustomProvider {
    host: 'CustomProvider',
    connection: HttpProvider {
      withCredentials: false,
      timeout: 0,
      headers: undefined,
      agent: undefined,
      connected: false,
      host: '',
      httpAgent: [Agent]

Any idea about how to connect web3-eth-miner to my rpc server?

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.