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.

1
  • The same for me.
    – kitsune
    Mar 4, 2019 at 8:06

1 Answer 1

1

I had the same problem with [email protected]. Upgrade to [email protected] solved the problem.

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.