I would like to build my own BIP-44 Hierarchical Deterministic wallet to store my ethers and to make transactions (receive/send). I'm not interested to use an wallet app. I don't care about the language, I'm just looking for the safer and easiest way to go: I'm not good at programming, but I could do it .

  1. If Ethereumjs is the way to go, which ethereumjs package should I use?

    I have found from the ethereum.org website the ethereumjs team. But there are several way to build a wallet with them, for example, one way is explained in this tuto based on the individual ethereumjs repo (that have been moved to ethereumjs-monorepo) and another way is to use the ethereumjs-wallet. Which is the safest way?

    Edit: ethereumjs-wallet does not support signing transactions so it only leaves ethereumjs-monorepo for the ethereumjs-team. But it still leaved the second question.

  2. Or is there another way/package/programming language that is safer than ethereumjs?


After a lot of research, I went with ethereumjs-util, bip39 and hdkey.

A Installations
Install Node.js (npm will also be needed but it is included in node.js)

Then open a CMD and install the packages : You can do it in 2 ways:
Method A: install via the install @ethereumjs/tx command. This will install the package in C:\Users\<iuser>\node_modules\ and you can access them directly in the Node command.

npm install ethereumjs-util  
npm install bip39  
npm install hdkey  

Method B: install via a npm install -g @ethereumjs/tx command. It will install the package in C:\Users\<user>\AppData\Roaming\npm\node_modules, then you will need to create a folder let's call it folder_B and inside of it another folder named node_modules and then run a command on B like npm link @ethereumjs/tx (cf below, for each package), and after that you will be able to use them in the Node when it is open on folder_B.

npm install -g ethereumjs-util  
npm install -g bip39  
npm install -g hdkey  

npm link ethereumjs-util  
npm link bip39  
npm link hdkey  

B Creating a mnemonic
B1) preparing the environnement : Open a cmd (if you use method A it can be started anywhere, if you use methob B it should started on folder_B) Type node then press Enter Once the node console is loaded (cf the message "welcome to node...), type:

bip39 = require('bip39');  
ethUtil = require('ethereumjs-util');  
hdkey = require('hdkey');  

B2) generating the mnemonic

const mnemonic = bip39.generateMnemonic(256);
console.log( "mnemonic: ", mnemonic)  

C Deriving an address from a specific path in your wallet
C1) If you still have the node console open from the Step B, you can continue to step C2, otherwise, first do the step B1 and save your mnemonic in a variable like this:

const mnemonic = "replace this by your mnemonic"    

C2) From the mnemonic to the master private key

const seed = bip39.mnemonicToSeedSync(mnemonic);  
const root = hdkey.fromMasterSeed(seed);  
const masterPrivateKey = root.privateKey.toString('hex');  

C3) From the path to the address

var path = "m/44'/60'/0'/0/0"  // change path   
var addrNode = root.derive(path);   
var pubKey = ethUtil.privateToPublic(addrNode._privateKey);  
var addr =  '0x' +  ethUtil.publicToAddress(pubKey).toString('hex');  
var address = ethUtil.toChecksumAddress(addr);  

console.log( "\n", "\n", "\n","ACCOUNT ", path, "\n", "private key : 0x", addrNode._privateKey.toString('hex'), "\n", "public key : ",pubKey.toString('hex'), "\n", "address : ", address)  

C4) To get different address, you can rerun C3 with a different path each time, just change the last and/or third last number*. Some examples:

  • this is the meaning of the path (you only have to change the account and the address_index) : m / purpose' / coin_type' / account' / change / address_index

If you don't intent to use this wallet to hold real ETH, then you can verify the address, and the private/public key on for https://iancoleman.io/bip39/

D Once you are done, delete nodejs history :
In a CMD...

cd %userprofile%  
echo. > .node_repl_history  

Or delete file : C:\Users\<user>\.node_repl_history

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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