Connection Error when tuffle console

Hello people,

I am unable to connect to Ropsten due to this error:

this is my config file, I do not get what is going wrong


const HDWalletProvider = require("@truffle/hdwallet-provider");
const infuraKey = "********";
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();

module.exports = {
  networks: {
   development: {
      provider: () =>
        new HDWalletProvider(mnemonic, "http://127.0.0.1:7545"),
        network_id: "*" // Any network (default: none)
    },
    geth: {
      provider: () =>
      new HDWalletProvider(mnemonic, "http://127.0.0.1:8545"),
      network_id: "*"
    },
    ropsten: {
      provider: () => new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/*********"),
      network_id: 3,       // Ropsten's id
      gas: 5500000,        // Ropsten has a lower block limit than mainnet
      confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
    },

    // Useful for private networks
    private: {

    }
  },

  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
       version: "0.5.2",
    }
  }
}
1 Like

I run your code in my own computer and change the ropsten key to mine and the code work with no errors. make sure that your key is correct. and make sure that @truffle/hdwallet-provider installed. you can use npm i --save @truffle/hdwallet-provider ,or send me your full code i’ll test it.

1 Like

thanks a lot for your answer.

I checked my keys and I am sure the wallet is installed.
I have then a file called:

.secret

with the seed pasted inside. No special characters, just the seed words

I have no probs sharing the full code here:


const HDWalletProvider = require("@truffle/hdwallet-provider");
const infuraKey = "cb6c3f230a4b42d7a28bad2c906d69c8";
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();

module.exports = {
  networks: {
   development: {
      provider: () =>
        new HDWalletProvider(mnemonic, "http://127.0.0.1:7545"),
        network_id: "*" // Any network (default: none)
    },
    geth: {
      provider: () =>
      new HDWalletProvider(mnemonic, "http://127.0.0.1:8545"),
      network_id: "*"
    },
    ropsten: {
      provider: () => new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/2e7b29597857442bac68cded43336092"),
      network_id: 3,       // Ropsten's id
      gas: 5500000,        // Ropsten has a lower block limit than mainnet
      confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
    },

    // Useful for private networks
    private: {

    }
  },

  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
       version: "0.5.2",
    }
  }
}

also I have installed the wallet once again

Hi @Dani_M not clear from this image the error you’re receiving, can you provide the full error response?

1 Like

Hello Mike, below the full text:

truffle(ropsten)> Error: CONNECTION ERROR: Couldn't connect to node https://ropsten.infura.io/v3/2e7b29597857442bac68cded43336092.

    at Object.InvalidConnection (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-core-helpers/src/errors.js:35:16)

    at HttpProvider.send (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-providers-http/src/index.js:109:25)

    at ProviderSubprovider.handleRequest (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/subproviders/provider.js:16:17)

    at next (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:119:18)

    at FilterSubprovider.handleRequest (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/subproviders/filters.js:89:7)

    at next (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:119:18)

    at NonceTrackerSubprovider.handleRequest (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/subproviders/nonce-tracker.js:79:7)

    at next (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:119:18)

    at HookedWalletSubprovider.handleRequest (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/subproviders/hooked-wallet.js:234:7)

    at next (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:119:18)

    at Web3ProviderEngine._handleAsync (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:106:3)

    at EthQuery.sendAsync (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-query/index.js:66:24)

    at EthQuery.getBlockByNumber (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-query/index.js:80:10)

    at /Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/pify/index.js:29:7

    at new Promise (<anonymous>)

    at EthQuery.<anonymous> (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/pify/index.js:12:10)

    at EthQuery.ret (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/pify/index.js:56:34)

    at RpcBlockTracker._fetchBlockByNumber (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-block-tracker/src/index.js:200:47)

    at RpcBlockTracker._performSync (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-block-tracker/src/index.js:120:35)

    at RpcBlockTracker.start (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-block-tracker/src/index.js:62:12)

    at processTicksAndRejections (internal/process/task_queues.js:94:5)

Error: CONNECTION ERROR: Couldn't connect to node https://ropsten.infura.io/v3/2e7b29597857442bac68cded43336092.

    at Object.InvalidConnection (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-core-helpers/src/errors.js:35:16)

    at HttpProvider.send (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-providers-http/src/index.js:109:25)

    at ProviderSubprovider.handleRequest (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/subproviders/provider.js:16:17)

    at next (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:119:18)

    at FilterSubprovider.handleRequest (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/subproviders/filters.js:89:7)

    at next (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:119:18)

    at NonceTrackerSubprovider.handleRequest (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/subproviders/nonce-tracker.js:79:7)

    at next (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:119:18)

    at HookedWalletSubprovider.handleRequest (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/subproviders/hooked-wallet.js:234:7)

    at next (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:119:18)

    at Web3ProviderEngine._handleAsync (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/web3-provider-engine/index.js:106:3)

    at EthQuery.sendAsync (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-query/index.js:66:24)

    at EthQuery.getBlockByNumber (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-query/index.js:80:10)

    at /Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/pify/index.js:29:7

    at new Promise (<anonymous>)

    at EthQuery.<anonymous> (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/pify/index.js:12:10)

    at EthQuery.ret (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/pify/index.js:56:34)

    at RpcBlockTracker._fetchBlockByNumber (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-block-tracker/src/index.js:200:47)

    at RpcBlockTracker._performSync (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-block-tracker/src/index.js:120:35)

    at Timeout._onTimeout (/Users/xxxxxxxxxxxxxxxx/Documents/Code/SolidityAdvanced/CoinFlip/node_modules/eth-block-tracker/src/index.js:110:27)

    at listOnTimeout (internal/timers.js:531:17)

    at processTimers (internal/timers.js:475:7)

I was able to deploy another contract on the Ropsten network, which means that the error I am facing must be somewhere in the contract itself

Hi @Dani_M, I tested your API key and it appears to be working fine. Can you confirm you are able to send any requests to your API key?

Hey @mike,

I do show that the contract is deployed in truffle but then fails when import provable api:

any idea why?

1 Like

I’m facing the exact same issue here.

const HDWalletProvider = require("@truffle/hdwallet-provider");
const mnemonic = "bargain swim ...";
ropsten: {
      provider: () => new HDWalletProvider(mnemonic, 'https://ropsten.infura.io/v3/XXX'),
      network_id: 3, // Ropsten's id
      gas: 5500000, // Ropsten has a lower block limit than mainnet
      confirmations: 2, // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200, // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
}

Error: CONNECTION ERROR: Couldn't connect to node https://ropsten.infura.io/v3/XXX

Full log:

Error: CONNECTION ERROR: Couldn't connect to node https://ropsten.infura.io/v3/XXX.
    at Object.InvalidConnection (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-core-helpers\src\errors.js:35:16)
    at HttpProvider.send (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-providers-http\src\index.js:109:25)
    at ProviderSubprovider.handleRequest (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\subproviders\provider.js:16:17)
    at next (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\index.js:119:18)
    at FilterSubprovider.handleRequest (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\subproviders\filters.js:89:7)
    at next (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\index.js:119:18)
    at NonceTrackerSubprovider.handleRequest (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\subproviders\nonce-tracker.js:79:7)
    at next (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\index.js:119:18)
    at HookedWalletSubprovider.handleRequest (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\subproviders\hooked-wallet.js:234:7)
    at next (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\index.js:119:18)
    at Web3ProviderEngine._handleAsync (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\web3-provider-engine\index.js:106:3)
    at EthQuery.sendAsync (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\eth-query\index.js:66:24)
    at EthQuery.getBlockByNumber (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\eth-query\index.js:80:10)
    at E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\pify\index.js:29:7
    at new Promise (<anonymous>)
    at EthQuery.<anonymous> (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\pify\index.js:12:10)
    at EthQuery.ret (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\pify\index.js:56:34)
    at RpcBlockTracker._fetchBlockByNumber (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\eth-block-tracker\src\index.js:200:47)
    at RpcBlockTracker._performSync (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\eth-block-tracker\src\index.js:120:35)
    at Timeout._onTimeout (E:\MAMP_V3\htdocs\solidity\demo-app\node_modules\eth-block-tracker\src\index.js:110:27)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

Update:

I’ve successfully connected using the same project ID on another device. However I still need to resolve this on the device that is erroring as above. Both devices are using identical configs, only thing I can think of is a version incompatibility:

Erroring device:
Truffle v5.1.12 (core: 5.1.12)
Solidity - 0.6.0 (solc-js)
Node v12.16.0
Web3.js v1.2.1

Non-erroring device:
Truffle v5.1.13 (core: 5.1.13)
Solidity - 0.6.0 (solc-js)
Node v10.14.1
Web3.js v1.2.1

It’s s node js bug. Works if you downgrade to node 10.*

It took 5 days to me to figure that out :expressionless:

2 Likes