question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hdwallet-provider requires plaintext mnemonic

See original GitHub issue
  • I’ve asked for help in the Truffle Gitter before filing this issue.

Issue

hdwallet-provider requires plaintext mnemonic.

Steps to Reproduce

I want to deploy a contract to a network using truffle/hdwallet-provider and truffle migrate --network rinkeby, for example. Accordingly, I’ve defined by truffle-config.js file like so:

const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".keysToTheKingdom").toString().trim();

const infuraURL = 'https://rinkeby.infura.io/v3/MY-PROJECT-ID'
const infuraKey = fs.readFileSync(".infuraProjectSecret").toString().trim();

var HDWallet = require('@truffle/hdwallet-provider')

module.exports = {
  networks: {
      rinkeby: {
	  provider: () => new HDWalletProvider(mnemonic, infuraURL),
	  network_id: 4,       // Rinkeby's network id 
	  gas: 5500000,
      },
};

This works, but requires me to store my mnemonic on my host in plaintext somewhere. This is insecure, regardless of the fact that I’m storing it in a hidden file.

Expected Behavior

Do not require plaintext wallet mnemonics to deploy to networks. Instead, some public keys or a hash of the wallet mnemonic should be provided.

Or some other workaround?

Actual Results

Deployment to network works, but this requires storing wallet mnemonics in plaintext on the host somewhere. If the host becomes compromised, the keys to the kingdom, and my entire net worth, are lost. Storing this in plaintext is wild because of how critical this mnemonic is. It’s 2020 - we don’t store passwords in plaintext in a file on our host… why should we do it with something so critical as a wallet mnemonic?

Environment

  • Operating System: Ubuntu 18.04
  • Ethereum client: geth v1.9.21
  • Truffle version (truffle version): 5.1.43
  • node version (node --version): 8.10.0
  • npm version (npm --version): 6.14.8

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
freddyshimcommented, Jun 8, 2021

I’m surprised this issue hasn’t been given a larger priority. Sure, we can circumvent the security issue by using a development account with a different mnemonic phrase, but I shouldn’t have to download multiple Metamask extensions on different browsers just so that I can test my projects with an ease of mind.

3reactions
sterlingcrispincommented, Jun 8, 2021

I agree this is crazy and should be fixed – I’m sure this is being targeted by hackers trying to gain access to big wallets. This should be a must-fix issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

'truffle migrate' will compile but not do anything else
I am on node 10.15.3, truffle 5.0.8, and solc 0.5.6. I cannot figure out how to get past this issue as there are...
Read more >
Deploying Truffle contracts to all networks without running ...
var HDWalletProvider = require(“truffle-hdwallet-provider”);. Then, you need to declare your mnemonic phrases. ... Text to speech.
Read more >
How to add private keys to deploy a smart contract to Roptsen?
The mnemonic private key is from a metamask wallet. This is what is in the truffle.config file now: require('babel-polyfill'); require ...
Read more >
Ethereum JavaScript Libraries: web3.js vs. ethers.js (Part II)
const HDWalletProvider = require('@truffle/hdwallet-provider');. (HDWalletProvider will return undefined). Next add in your mnemonic:
Read more >
Send clear text message on EVM blockchains with Web3.js
The @truffle/hdwallet-provider library is optional. We use it to easily import a wallet through an MNEMONIC. Like this: const MNEMONIC = ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found