2

I'm getting the following error when I try to deploy my smart contract to Rinkeby using Truffle:

Error: Unknown arguments format passed to new HDWalletProvider. Please check your
configuration and try again

Note: I haven't had any problems deploying this same contract locally using Truffle, only to Rinkeby.

Here's my code:

require('dotenv').config();
const HDWalletProvider = require('@truffle/hdwallet-provider');  

module.exports = {
  networks: {
     development: {
        host: "127.0.0.1",     
        port: 8545,            
        network_id: "*",   
     },

     rinkeby: {
        provider: () => new HDWalletProvider(process.env.RINKEBY_MNENOMIC, 
        "https://rinkeby.infura.io/v3/${process.env.INFURA_API_KEY}"),
         host: "127.0.0.1", 
         network_id: 4,
         gas: 4612388,
         gasPrice: 10000000000
     },
 },

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

}

I'm wondering if this is some sort of version issue cause I'm seeing that my previous contracts used 'truffle-hdwallet-provider', while this one is using '@truffle/hdwallet-provider'

Meanwhile, my .env file contains the following:

#MNENOMIC="word1 word2 word3, ...word12"
RINKEBY_MNENOMIC="word1 word2 word3, ...word12"
PRODUCTION_MNENOMIC="word1 word2 word3, ...word12"

INFURA_API_KEY="xxxxxxxxxxxxxxxxxxxx"

So what might be happening here? What is this Unknown arguments format passed to new HDWalletProvider error all about?

2 Answers 2

2

Looks like it was a version thing.

According to Truffle's official readme (available here: https://github.com/trufflesuite/truffle/tree/develop/packages/hdwallet-provider#truffle-usage) the way to do this now is as follows:

rinkeby: {
  provider: () =>
    new HDWalletProvider({
      mnemonic: {
        phrase: rinkebyMnemonic
      },
      providerOrUrl: "https://rinkeby.infura.io/v3/" + infuraKey,
      numberOfAddresses: 1,
      shareNonce: true,
    }),
  network_id: '4',
}
0

You may also try installing the wallet handler with the following commaind:

#~>npm install truffle-hdwallet-provider

Then on your truffle-confi.json have the following:

var mnemonicPhrase = "word1 word2 word3 ....word12";
var HDWalletProvider = require("truffle-hdwallet-provider");

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    },
    rinkeby: {
        // must be a thunk, otherwise truffle commands may hang in CI
      provider: () =>
      new HDWalletProvider(mnemonicPhrase, "https://rinkeyb.infura.io/v3/YOUR-INFURA-PROJECT-KEY"),
      network_id: '4',
    }
  },

  compilers: {
    solc: {
      version: '0.8.9',
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
};

then try run with truffle: truffle migrate --network rinkeby

You can also replace the infura "https://rinkeyb.infura.io/v3/YOUR-INFURA-PROJECT-KEY" with Alchemy "https://eth-rinkeby.alchemyapi.io/v2/YOUR-ALCHEMY-JEY"

Your Answer

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

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