Web3j Wallet Path for Credentials – Comprehensive Guide

go-ethereumjson-rpcweb3j

I am using the readme guide https://github.com/web3j/web3j. What I am interested is developing smart contracts from my host with java + web3j to private ethereum network which runs on my virtual machine. There are such lines:

Web3j web3 = Web3j.build(new HttpService());  // defaults to http://localhost:8545/
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile");

So the question is – how should I create this wallet? Should I generate account on my VM and then copy wallet.json file to my host?

Best Answer

The wallet file is your encrypted private key file. you have the choice to :

1-use the private key file from the web3js or ethereum keystore.

AppData/Ethereum/keystore (geth)
AppData/Web3/keys (eth)

you will find something like :

Ethereum\keystore\UTC--2017-1-20T11-51-50.069518500Z--637f383c240g512be19d3ffa3b45d7f03babf091

use it a second parameter in WalletUtils.loadCredentials

2- creating the wallet fine using web3j

String fileName = WalletUtils.generateNewWalletFile(
        "your password",
        new File("/path/to/destination"));

3-use Myetherwallet to export your 'wallet' as a json file.

Related Topic