3

I want to access MyEtherWallet account address from truffle-hdwallet-provider.

This is the code.

```

var HDWalletProvider = require("truffle-hdwallet-provider");
var privateKey = process.env.KEY;
var infuraApiKey = process.env.INFURA;

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*"
    },
    mainnet: {
      provider: function () {
        return new HDWalletProvider(
          privateKey,
          "https://mainnet.infura.io/" + infuraApiKey
        );
      },
      network_id: 1,
      gas: 2000000,
      gasPrice: 3000000000 // 3 Gwei
    }
  }
};

```

In process.env.KEY, there are correct private key. It is correct because I can access my account using this private key.

However, I run truffle console --network mainnet and chek my address web3.eth.getAccounts(function(err, res){console.log(res)}), it returns wrong address.

Why??

The private key is correct, but I can't access another address I don't know. Why??

Thanks in advance.

  • The same for me. – kitsune Mar 4 at 8:06
0

I had the same problem with truffle-hdwallet-provider@1.0.0-web3one.0. Upgrade to truffle-hdwallet-provider@1.0.8 solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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