1

I was playing with web3.eth.accounts.create() and web3.eth.accounts.wallet.create functions, and reading web3 docs about it. I know that an externally-owned account is the same as a wallet, you have an adddress and a private key associate to it.

I have been reading similar posts like this or this but they don't explain the difference between:

  1. web3.eth.accounts.create
  2. web3.eth.accounts.wallet.create

Are both analogous and give a similar result?

With both I get the same properties:

 - address: "0x..."
 - encrypt: function encrypt(r, n) 
 - privateKey: "..."
 - sign: function sign(r)​ 
 - signTransaction: function signTransaction(r, n)
0

web3js defines a wallet as a set of public/private key pairs, or, in other words, a set of EOAs.

web3.eth.accounts.create allows to generate a single EOA whereas web3.eth.accounts.wallet.create enables the creation of multiple accounts.

For example :

//create two EOAs
const wallet = web3.eth.accounts.wallet.create(2, 'test');
//get first account properties
account_1 = wallet[0];
//get second account properties
account_2 = wallet[1];
// get first account private key
privateKey_1 = account_1.privateKey;
//get second account address
address_2 = account_2.address;

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.