Im using the Web3j library to make transactions with my blockchain (Ganache).

I have a method that instantiate a Web3j object and im trying to generate a new account with the given

String url = "http://localhost:7545/";
        Web3j web3j = Web3j.build(new HttpService(url));


        try {
            ECKeyPair keyPair = Keys.createEcKeyPair();
            WalletFile wallet = Wallet.createStandard(key, keyPair);

            System.out.println("Private key: " + keyPair.getPrivateKey().toString(16));
            System.out.println("Account: " + wallet.getAddress());

enter image description here enter image description here

But when in the power shell console I connect to ganache using Geth I dont have the new address in the eth.accounts().

What i have to make??

1 Answer 1


I think there is a little bit of confusions.

eth.accounts returns the list of accounts managed and owned by your node. It means the lists of private keys stored on your node keystore.

  • With Ganache, it's a set of randomly generated accounts
  • With Geth, it's in $HOME/.ethereum/keystore
  • With Parity, it's in $HOME/.local/share/io.parity.ethereum/keys/

When you connect a program to the node, the private key generated by the program is theoretically owned by the program and not by the node. That's why you're not seeing this account on the node account lists.

But you can still use this account (keypair) to send transactions through this node.

  • And is posibble to save that account inside ganache?? Or I have to create a VM and insert de wallet file?? Thx Jan 28, 2019 at 13:44
  • Why not just simply create your Web3j wallet from one of the Ganache private key like that: ECKeyPair keypair = ECKeyPair.create(privateKey) Jan 28, 2019 at 16:51

Your Answer

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

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