[Ethereum] Accounts created by using web3.eth.accounts.create() don’t appear when web3.eth.getAccounts(console.log)

accountsweb3js

I am new to Ethereum.

I am running a geth devnode.

Installed web3.

Used web3.eth.accounts.create function to create one account without any entropy and created another account by using the same command with entropy – for both these, I was given the address and private key for the accounts.

Then when I query web3.eth.getAccounts(console.log), the reply did not include the newly created accounts.

Any information on why these newly created accounts aren't listed?

On node command prompt, I did these:

Web3 = require('web3');
web3 = new Web3('localhost:8545');
web3.eth.accounts.create(); //this gave me the address and the private key for the first account
web3.eth.accounts.create("aaabbbb"); //this gave me the address and the private key for the 2nd account
web3.eth.getAccounts(console.log); //the list this gives doesn't have the two accounts I created by the above steps 

Thanks in advance

Best Answer

web3.eth.getAccounts will only return a list of accounts controlled by node. Accounts created through web3.eth.accounts.create will not be listed here. for creating accounts on node using web3 use web3.eth.personal.newAccount()

Related Topic