i have setup private blockchain on vm using geth and i have created personal account for deployment of contract on private blockchain. Now, when i try to create new account, i am able to do so but i cannot see that account when i try get list of all accounts.

{ address: '0xF3E6A7c5A9D92A89054C582bCe92d4defA741459',
  signTransaction: [Function],
  sign: [Function],
  encrypt: [Function] }
> web3.eth.getAccounts().then(console.log);
Promise {
   Domain {
     domain: null,
      [Object: null prototype] {
        removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [] } }
> [ '0x5907Ed57f77E5d8eb6fC39807b07b8f8803eE608' ]

It is only listing personal account.


When we create an account using web3.eth.accounts.create(), it returns you the ethereum address and the private key for that account. This allows you to store the private key locally. The key-pair is only created on the client and it's up to the developer to manage it. So, here the accounts are actually not created on the node or in your case - the private blockchain.

But in case of personal account, the ethereum acount is created over the network on the node via an RPC call. In this case, the private key will not be returned to you. And since you don’t have the private key, you can’t sign transactions locally. You have to call unlockAccount method to unlock your account and sign the transactions. For this you will be required to have the password with which you created the account.

Conclusion - web3.eth.accounts.create() does not create account on node, that's why you don't see them when you call getAccounts() whereas accounts created using personal can be seen as they are created on the node via an RPC call.

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.