在web3j中使用ganache帐户

MrK*_*750 3 blockchain ethereum truffle web3-java

当尝试使用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");
Run Code Online (Sandbox Code Playgroud)

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

mah*_*sif 6

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

Credentials credentials = Credentials.create("0x78c0cf2c035dda3c46953fb7b926f8ece0aa8bfed6c012e33d5e289e6e0c1ebc");
Run Code Online (Sandbox Code Playgroud)