1

I am trying to create account on ethereum private network using web3js from front end. I have written the below lines in my js file. The createAccount() gets called from an HTML page

web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));

function createAccount(){    
    console.log("web3 version"+web3.version.api);
    web3.eth.accounts.create();
}

I get the below in the console web3 version0.20.1

Uncaught TypeError: web3.eth.accounts.create is not a function

Is it possible to create account on the node from front end html page using web3js? If not then what are the steps for doing the same from web3j.

0

Prior to version 1.0 of web3js - which has the eth.accounts functionality; creating a new account is achieved via


eth.personal.newAccount('password')

which you can find documented here

That said, to achieve this via Node.js you will need to enable 'personal' via RPC - which is inadvisable - or connect via IPC. See this existing answer for more details.

More information on the rpc flag, and parameter, that you would have to provide to enable this can be found on this web3js issue.

2

web3.eth.accounts.create is not available below web3.js 1.0.

Please refer notes section in this link Web3 JS accounts

  • What are the version numbers for web3? I've seen talk of 1.0. When you npm install it says 0.2.0, and the repo says 0.14. What is going on? – zero_cool Apr 5 '18 at 19:23
  • @Kaviarasu , What is alternative for it? – Alireza Zojaji Nov 24 '18 at 23:07

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.