0

I want to create an account using web3js and I need to the accounts private key in the same script. Are there any npm packages or web3 commands that would let me do that?

An example of what I would want to do:

privateKey = web3.CreateAccount();

1 Answer 1

3

This can be done with web3 1.0 like this

account = web3.eth.accounts.create([entropy]);

account is an object with the following structure:

address - string: The account address.

privateKey - string: The accounts private key. This should never be shared or stored

The object also gives you functions to sign transactions. For more details see the related web3 documentation

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.