0

I've been trying to compile my solidity smart contracts So I'd be able to deploy them on the Ropsten Test network when I run truffle compile I get this error :

TypeError: mnemonic.includes is not a function at normalizePrivateKeys

I don't understand what this typeError means

here's the full message:

TypeError: mnemonic.includes is not a function
    at normalizePrivateKeys (C:\Users\aliya\node_modules\@truffle\hdwallet-provider\src\index.ts:62:38) 
    at new HDWalletProvider (C:\Users\aliya\node_modules\@truffle\hdwallet-provider\src\index.ts:102:25)
    at Object.<anonymous> (C:\Users\aliya\ethereum\supplychain\truffle-config.js:31:23)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at Object.require (internal/modules/cjs/helpers.js:77:18)
    at Function.load (C:\Users\aliya\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\config\dist\index.js:161:1)
    at Function.detect (C:\Users\aliya\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\config\dist\index.js:150:1)
    at Object.run (C:\Users\aliya\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\compile.js:53:1)
    at Command.run (C:\Users\aliya\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\command.js:136:1)
    at Object.<anonymous> (C:\Users\aliya\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\cli.js:51:1)
    at __webpack_require__ (C:\Users\aliya\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap:19:1)
    at C:\Users\aliya\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap:83:1
    at Object.<anonymous> (C:\Users\aliya\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:89:10)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47

using Solidity 0.6.8

Truffle v5.1.26 (core: 5.1.26)

Node v12.16.2

and This is my truffle-config file:


const HDWalletProvider = require("@truffle/hdwallet-provider"); 
const Wallet = require("ethereumjs-wallet.js"); //this line gives

let mainNetPrivateKey = new Buffer(secrets.mainnetPK, "hex");
let mainNetWallet = Wallet.fromPrivateKey(mainNetPrivateKey);
let mainNetProvider = new HDWalletProvider(
  mainNetWallet,
  "https://mainnet.infura.io/v3/***"
);

let ropstenPrivateKey = new Buffer(secrets.ropstenPK, "hex");
let ropstenWallet = Wallet.fromPrivateKey(ropstenPrivateKey);
let ropstenProvider = new HDWalletProvider(
  ropstenWallet,
  "https://ropsten.infura.io/v3/***"
);


module.exports = {  
  networks: {

    development: {
      host: "localhost", // Localhost (default: none)
      port: 7545, // Standard Ethereum port (default: none)
      network_id: "*",
      gas: 4465030, // Any network (default: none)
    },
    ropsten: {
      provider: ropstenProvider,
      network_id: "3",
      gas: 4465030,
    },
    live: {
      provider: mainNetProvider,
      network_id: "1",
      gas: 7500000,
    },
   },

  compilers: {
    solc: {
      version: "0.6.8", 
      },

       }
    },
  },

Any help would be awesome!

1 Answer 1

0

There are couple of thing that needs to be fixed

  • From the hdwallet-provider documention the first parameter is the mnemonic or the private key. It will fail since you are passing a ethereumjs-wallet instance instead.

  • From Truffle documentation a provider should be returned by function. Passing an instance is not correct.

For example in case of ropsten something like this should work:

    ropsten: {
      provider: function () {
        return new HDWalletProvider(
          secrets.ropstenPK,
          "https://ropsten.infura.io/v3/***"
        );
      },
      network_id: "3",
      gas: 4465030,
    },

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.