2

Can anyone explain the difference between

`eth.accounts.create()` and `eth.personal.newAccount()`

and which one we should use and why? As I am new to ethereum so its very confusing for me. Thanks

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

From the documentation the definition for both is a little bit different


eth.accounts

The web3.eth.accounts contains functions to generate Ethereum accounts and sign transactions and data.

There is only one paramater which is

  • entropy - String (optional): A random strong to increase entropy. If given it should be at least 32 characters. If none is given a random string will be generated using randomhex.

Also eth.accounts.create() will return an object that contains

  • address - string: The account address.
  • privateKey - string: The accounts private key.
  • signTransaction(tx [, callback]) - Function: The function to sign transactions.
  • sign(data) - Function: The function to sign transactions

eth.personal

The web3.eth.personal package allows you to interact with the Ethereum node’s accounts.

There is also only one parameter but it allows you to set the password

  • password - String: The password to encrypt this account with.

And you only get a string as return which is

  • Promise returns String: The address of the newly created account.

There is not much more information about it, but I guess you would use the one that suits your need the most. In most case you should probably use eth.accounts because it gives you back much more information.

Source : web3.js - Ethereum JavaScript API

  • account created by using eth.accounts.create(), not showing in eth.accounts list. Also Is there any need to unlock that newly created account (by using eth.accounts.create()) – Amit Sharma Dec 22 '17 at 10:03
  • @AmitSharma The getAccounts method returns a promise are you sure you're waiting for it? – I.B Dec 22 '17 at 15:34
0

Typically, the personal module lets you interact with "locked" accounts which require a password to take an action. The eth.accounts module lets you interact with already unlocked accounts, that do not require a password to take an action.

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.