在 web3j 中使用 ganache 账户

Use ganache accounts in web3j

尝试使用 https://github.com/web3j/sample-project-gradle 时遇到此代码:

    // 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");

我想使用 ganache-cli 创建的网络。我确实成功连接到网络,但找不到钱包文件。有没有办法在这里使用由 ganache-cli 生成的帐户?

ganache-cli 是个人区块链。它不创建钱包文件,而是提供私钥来加载凭据。

Credentials credentials = Credentials.create("0x78c0cf2c035dda3c46953fb7b926f8ece0aa8bfed6c012e33d5e289e6e0c1ebc");