0

There is a site with simple registration and user login. How can I create a new ethereum account for each new user and store the keys of these accounts in my database

Madox
  • 13
  • 2
  • You can use a HD wallet https://ethereum.stackexchange.com/questions/39384/how-to-generate-private-key-public-key-and-address – Ismael Nov 25 '19 at 03:51
  • @Ismael Is it possible to use web3.eth.accounts.create()? – Madox Nov 25 '19 at 10:47

1 Answers1

0

Try this:

const crypto = require("crypto");
const util = require("ethereumjs-util");

const privateKey = "0x" + crypto.randomBytes(32).toString("hex");
const publicAddr = "0x" + util.privateToAddress(privateKey).toString("hex");
goodvibration
  • 26,003
  • 5
  • 46
  • 86