Spectrum is now read-only. Learn more about the decision in our official announcement.

Truffle Suite

Sweet tools for smart contracts


ganache-cli unlock any account

August 26, 2020 at 10:54am

ganache-cli unlock any account

August 26, 2020 at 10:54am this is an old link, but could anyone highlight the -u flag, I know it can be used to send transactions as any account, but how can I unlock an account after ganache-cli has started? same answer for forking as well?

August 26, 2020 at 11:28am
some additional context, I am using ethers to communicate to the forked blockchain. I need to know how to send transactions from an address , which I don't have a private key too
const options = {
const provider = new ethers.providers.Web3Provider(ganache.provider(options))
here's what happens when I try to unlock it
when I unlock an account that is generated
In general you need to have unlocked the account to access it. The -u options lets you unlock during startup. I think you will just need to use a provider that allows you to access the account you are interested in by means of a mnemonic or private keys.
I hope that was helpful. The one I'm most familiar with is our package /hdwallet-provider. For that you need a mnemonic or private keys to use the account.
hmm, but the docs of ganache-cli say that I can use any account for testing/debugging
the -u flag is equivalent to unlocked_accounts in the options yes?
Yes but you need to unlock it on Ganache startup or afterwards with your provider.
I'm not sure what you mean by "... is equivalent to unlocked_accounts"
Can you clarify a little bit more?
pls refer to this for what I mean by unlocked_accounts
also, could you send a snippet on how to unlock it with my provider after ganache has started?
this is what happens when i try to unlock an account
I can use signer.sendUncheckedTransacion for the unlocked account in that array, my question is how do I add more accounts to the unlocked_accounts array after ganache has started?
(tcoulter) I think you worked on this on

August 27, 2020 at 2:58pm
I need help with this asap!
Show more messages