Vikramaditya
Vikramaditya

Reputation: 5574

How to create ether wallet?

I want to create users ether wallet through code. is there any api or something to create ether wallet which they can use to transfer & receive ether ?

Upvotes: 4

Views: 4302

Answers (3)

Vikramaditya
Vikramaditya

Reputation: 5574

First of all Ethereum network doesn't provide any API to create wallet. Any 40 digit hexadecimal string is a valid ethereum wallet with 0x as prefix. Each wallet is created using some private key. Private key is 64 digit hexadecimal string.

Ex: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa is a valid private key.

And you will find address corresponding to this private key to be 0x8fd379246834eac74B8419FfdA202CF8051F7A03

Private keys should be very strong. So practically it is created by key derivative function.

For Node.js i use keythereum

function createWallet(password) {
  const params = {keyBytes: 32, ivBytes: 16};
  const dk = keythereum.create(params);

  const options = {
    kdf: 'pbkdf2',
    cipher: 'aes-128-ctr',
    kdfparams: { c: 262144, dklen: 32, prf: 'hmac-sha256' }
  };
  const keyObject = keythereum.dump(password, dk.privateKey, dk.salt, dk.iv, options);
  return keyObject;
}
 /* for getting private key from keyObject */
function getPrivateKey(password, keyObject) {
  return keythereum.recover(password, keyObject);
}

const keyObject = createWallet("My Super secret password");
const walletAddress = '0x' + keyObject.address;

const privateKey = getPrivateKey("My Super secret password", keyObject);

Upvotes: 2

q9f
q9f

Reputation: 11824

You can use web3py.

$ pip install web3

Add any provider on the node you are running:

>>> from web3 import Web3, KeepAliveRPCProvider, IPCProvider

Note that you should create only one RPCProvider per process, as it recycles underlying TCP/IP network connections between your process and Ethereum node.

>>> web3 = Web3(KeepAliveRPCProvider(host='localhost', port='8545'))

Or for an IPC based connection:

>>> web3 = Web3(IPCProvider())

And voila:

>>> web3.personal.newAccount('the-passphrase')
['0xd3cda913deb6f67967b99d67acdfa1712c293601']

It created a new account.

Upvotes: 0

Abhilekh Singh
Abhilekh Singh

Reputation: 2943

You can use pyethapp (python based client) for creating ethereum wallet, transferring funds.

Link: https://github.com/ethereum/pyethapp

It has very simple command to create account

$ pyethapp account new

Explore examples also: https://github.com/ethereum/pyethapp/tree/develop/examples

Upvotes: 2

Related Questions