1

I am just trying to create a HD wallet with web3 and truffle to make receive some ethers. I have installed both of these packages with npm. Inside a node console, I am trying to run this to get a private/public key :

Bip39 = require("bip39");
const mnemonicPhrase = Bip39.generateMnemonic();

const HDWalletProvider = require("@truffle/hdwallet-provider");
Web3 = require('web3');


provider = new HDWalletProvider({
  mnemonic: mnemonicPhrase,
  providerOrUrl: "http://localhost:8545",
  numberOfAddresses: 1,
  shareNonce: true,
  derivationPath: "m/44'/0'/0'/0/"
});

const web3 = new Web3(provider);
web3.eth.accounts.create() 

I am running one piece of code after another and just after I run the provider = new HDWalletProvider(), I get this error:

Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: connect ECONNREFUSED 127.0.0.1:8545
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
    at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:131:14)
    at PollingBlockTracker._performSync (C:\Users\Me\node_modules\eth-block-tracker\src\polling.js:51:24)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {

Some people mentioning this error are fixing it with something like testrpc, geth --rpc that is apparently used to send the transaction on the ethereum network, but I don't want to do that, I just need to retrieve the private/public key in web3js. I really don't understand what I need to do to fix this.

1 Answer 1

-1

I had a similar error. I solved it by changing the IP address I had been trying to connect to.

from "https://10.161.162.12:8545" to "http://10.161.162.12:8554"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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