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",
    }
  }
}

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?