5

I am in the process of creating an app that will use Ethereum. I would like to create wallets for each of the users in my backend without them having to do anything except writing a passphrase.

What code should I use for that? can I use the Ethereum C++ client to do that? do I have to download all the blockchain to create wallets only?

eth
  • 85,679
  • 53
  • 285
  • 406
obaqueiro
  • 151
  • 3
  • 2
    You really shouldn't manage your client's wallets for them. That basically defeats the whole purpose of blockchains. Look into using https://github.com/ConsenSys/eth-lightwallet and https://github.com/ConsenSys/hooked-web3-provider – Tjaden Hess Sep 19 '16 at 00:48
  • Or Metamask, which makes it easy on your users. – Xavier Leprêtre B9lab Sep 19 '16 at 13:49

3 Answers3

1

You can realise this by using hd wallets technology. You can use just one passphrase and create a lot of addresses by using bip44 standard. So each your user will have public and private extended key, with public key they will able to create new addresses and with private key they will get all their resources.

You can find more info here

Il Kadyrov
  • 61
  • 5
0

You could have an endpoint on your application which takes in a passphrase from a user and generates a wallet with that passphrase using an RPC call to Ethereum's web3.personal.newAccount function. You can create wallets without downloading the blockchain.

thanos
  • 844
  • 1
  • 8
  • 20
0

The most well supported library for Ethereum currently is probably web3.js. Note: version 1 is still in beta so make sure you use v0.20.1, which is still the most well documented.

Then you'll need to run a server-side node which will support IPC connections (you could use HTTP RPC, but IPC is a little more secure). Geth and Parity will both do the job, but you only need one. Another note: you'll need to ensure you enable the personal IPC API if it's not on by default.

After that, you can generate accounts using web3:

const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.IpcProvider('/PATH/TO/IPC', require('net')

// make a new account, you can do this in a loop for all your users
let newAccount = web3.personal.newAccount("SOME_PASSWORD")

Footnote

This is pretty dangerous. Networks like Ethereum are fun because when you hold the private key to an easily-generatable account, you own all the assets in that account. When you put a bunch of private keys in one place, you create an attractive target for a hack. Be careful when handling lots of private keys, and ensure only the necessary people have access to them. Practise good opsec.

user2672053
  • 86
  • 1
  • 6