How can I get the raw private key from a WalletFile object?

Here is how I am creating the wallet.

String seed = UUID.randomUUID().toString();
ECKeyPair exKey = Keys.createEcKeyPair();

BigInteger privateKey = exKey.getPrivateKey();
BigInteger publicKey = exKey.getPublicKey();

WalletFile wallet = Wallet.createLight(seed,exKey);

Here is the code where I am sending a transaction,and I need the private key created previously.

Credentials credentials = Credentials.create("MY PRIVATE KEY");

 TransactionReceipt transactionReceipt = Transfer.sendFunds(
                    web3j, credentials, accountTo,

1 Answer 1


I found the solution to the problem, of how to get the private key after generate a wallet:

 Credentials credentials = Credentials.create(Wallet.decrypt(seed, wallet));

 String privateKeyGenerated = credentials.getEcKeyPair().getPrivateKey().toString(16);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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