I am trying to better understand how testing with test accounts should work. I have my contract and app working locally. I've setup truffle to now connect to ropsten network (via Infura). In that connection I have configured by secret phrase using mnemonics app. When I connect to ropsten and run await web3.eth.getAccounts() I see a list of 10 accounts. That leads me to some questions:

  1. Where did those accounts come from?
  2. For them to really be useful as a test account I need to be able to access them via Metamask, how do I do that?

1 Answer 1


Well there are a couple of things to understand here:

  • A mnemonic phrase does not only give access to just one Ethereum account but could actually be used to deterministically generate a list of Ethereum accounts and give access to each of them.
  • Each of those account has its own unique private key and each account is identified by an index in the account list (0, 1, 2, ...).
  • To import those accounts into Metamask: either do a fresh new install and import the seed phrase into it to be able to access that entire array of accounts, or copy and paste each private key to be able to access specific accounts without having to do a fresh install. Note that there are many derivation path format for seed phrases, so make sure that the format is consistent to be able to access the same accounts on Metamask.
  • How do I get the private keys of the accounts that were created?
    – gunygoogoo
    Commented Feb 20, 2022 at 0:31
  • @gunygoogoo Well here's how to do that in ethers: ethereum.stackexchange.com/questions/79317/… It doesn't seem to be included in web3. I suggest you switch to ethers asap just like I did. I feel like ethers is becoming the new standard in many ways. Commented Feb 20, 2022 at 12:06

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.