Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use ganache accounts in web3j

When trying to use https://github.com/web3j/sample-project-gradle I encounter this code:

    // We then need to load our Ethereum wallet file
    // FIXME: Generate a new wallet file using the web3j command line tools https://docs.web3j.io/command_line.html
    Credentials credentials =
            WalletUtils.loadCredentials(
                    "<password>",
                    "/path/to/<walletfile>");
    log.info("Credentials loaded");

I wanted to use network created by ganache-cli. I did successfully connect to the network but I can't find the wallet files. Is there a way to use here accounts generated by ganache-cli?

like image 226
MrKadek750 Avatar asked Oct 20 '25 17:10

MrKadek750


1 Answers

ganache-cli is a personal blockchain. It does not create wallet file, rather provides private key to load credentials.

Credentials credentials = Credentials.create("0x78c0cf2c035dda3c46953fb7b926f8ece0aa8bfed6c012e33d5e289e6e0c1ebc");
like image 192
mahfuj asif Avatar answered Oct 26 '25 12:10

mahfuj asif