0

I'm trying to deploy a contract to rinkeby using truffle. In the truffle-config file, in the HD wallet provider, you are supposed to specify a mnemonic and also your api from infura. The problem is that I do not have the mnemonic since metamask doesn't give you the option to export such and so all I have is the private key.

It doesn't work this way when I use my private key instead.

Here's a snippet of my code.

  rinkeby: {
  provider: () => new HDWalletProvider({
    privateKeys: private_keys,
    providerOrUrl: "https://rinkeby.infura.io/v3/a0f72a61273d4f1d9c5de301fecb8e64",
    numberOfAddresses: 2
  }),
  network_id: 4,       // Ropsten's id
  gas: 5500000,        // Ropsten has a lower block limit than mainnet
  confirmations: 2,    // # of confs to wait between deployments. (default: 0)
  timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
  skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )

Where const private_keys = ["..."] I get an error saying: TypeError: mnemonic.includes is not a function.

2 Answers 2

0

To access your MetaMask mnemonic seed phrase:

  1. Click on the MetaMask extension inside your browser and login.
  2. Go to My Accounts by clicking on the profile picture circle
  3. Click on the Settings option and then click Security and Privacy
  4. From there you can access your mnemonic seed phrase by clicking on the "Reveal Secret Recovery Phrase" button

I hope this answer will help!

0

Mnemonic gives you access to all accounts in metamask. Imagine you have 100 accounts in metamask, instead of remembering all the private keys for each account, you just save the mnemonic to retrieve all the accounts. The private key of an account is just responsible for that account, if somehow a malicious user gets access to this private key s/he will have control over that account. But if the malicious user gets your metamask mnemonics, s/he will have full control over your all accounts in metamask.

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.