I am aware of several tools and websites that generate addresses for you, but I'm looking for an actual JavaScript code snippet to demonstrate the steps plainly.

1 Answer 1


Take a look at :


( and mainly, this file, search for generateSingleWallet : https://github.com/kvhnuke/etherwallet/blob/gh-pages/js/source/01_global.js )

It is the source code for the https://www.myetherwallet.com/ that provides in-browser generation of ethereum addresses.

A simple javascript snippet (using CryptoJS and staticJS/01_ethereumjs-accounts.js libraries from the forementioned repository):

function generateSingleWallet(password) {
  // reference from staticJS/01_ethereumjs-accounts.js
  var acc = new Accounts();
  var newAccountEnc = acc.new(password);
  var addressHash =   
  addressHash = addressHash.substr(addressHash.length - 4);

  var newAccountUnEnc = acc.get(newAccountEnc.address, password);
  // now: newAccountUnEnc.private is unencoded private key
  newAccountEnc.private = newAccountEnc.private + addressHash;
  // now: newAccountEnc.private is encoded private key

  // always clear the Accounts object after generation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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