Is there a way in truffle develop tests to access the list of private keys in the same way we can access the list of accounts?

Basically, for every contract I need to test, the truffle test contract begins like :

contract("Testing Public Pool",function(accounts){....}

"accounts" is an array with the 10 default accounts generated by truffle when running the "truffle develop" command.

But is there a similar array for the private keys (that are also displayed when running the command)? I know I could copy/paste them manually but it is kind of annoying....

1 Answer 1


I think there are two possible solutions to this.

  1. The first is to use HDWalletProvider


You can configure it in your truffle-config.js

  1. Second approach would be to use mnemonics as explained in this answer:

How to get private keys on Truffle from Ganache accounts

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.