0

I found this way of creating a new ethereum account with web3j. But what if I want to create a wallet file for an already registered account? I need this because most of the web3j functions require a wallet file.

  1. Generate a key-pair Keys.createEcKeyPair()
  2. Create the wallet Wallet.createStandard(seed, keyPair)
1

you don't need always a wallet file, you can do something like this

/**
 * system wallet.
 */
private Credentials credentials;

/**
 * Get wallet from PrivateKey.
 * @param privateKeyInHex the private key
 */
private Credentials getCredentailFromPrivteKey(String privateKeyInHex) {
    BigInteger privateKeyInBT = new BigInteger(privateKeyInHex, 16);
    ECKeyPair aPair = ECKeyPair.create(privateKeyInBT);
    Credentials aCredential = Credentials.create(aPair);
    credentials = aCredential;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.