1

I want to get Etherum address and private key by adding Phrase (or Password) everytime. I tried by following many gihub code.It gives different private key everytime. In Web3j, I found it is based on file.

I want to make a programme in such a way that it will create same wallet again (Based on password or phrase).

Is there any way.If yes than please share your knowledge.

Kerem atam
  • 402
  • 3
  • 13
Kush
  • 111
  • 5

1 Answers1

2

I want to make a programme in such a way that it will create same wallet again (Based on password or phrase).

This is mostly called seed.

Refer to this answer : How to generate Private key, public key and address

const bip39 = require('bip39');
const hdkey = require('ethereumjs-wallet/hdkey');

const mnemonic = '..';
const hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic));
const path = "m/44'/60'/0'/0/0";
const wallet = hdwallet.derivePath(path).getWallet();
const address = `0x${wallet.getAddress().toString('hex')}`;

console.log(`Address: ${address}`);

Some good source for testing :

https://github.com/iancoleman/bip39

https://iancoleman.io/bip39/

Kerem atam
  • 402
  • 3
  • 13
  • I asked for Android. Please check title of the question – Kush Jul 21 '18 at 08:44
  • I've checked. Since you can use almost every language in every platform better do distinction as; Android is name of OS and Java is name of language. Better use (Android/Java) in your question and use tags like Java, ethereumj, web3j, etc.. I believe you have answer here : https://ethereum.stackexchange.com/questions/41072/generate-private-key-and-address-using-web3j and there : https://ethereum.stackexchange.com/questions/6673/generating-ethereum-private-key-public-key-on-mobile-android-java – Kerem atam Jul 21 '18 at 09:22
  • It works but everytime creates new wallet , new address and private key. – Kush Jul 23 '18 at 13:20
  • Did you try to change this line "String seed = UUID.randomUUID().toString();" in first link. You need to provide your seed word. – Kerem atam Jul 23 '18 at 14:22