Installing and using the Additional Modules

As per , I am trying to get this installed for use client side in a browser (chrome). I’ve followed the instructions

npm install bitcore-mnemonic
bower install bitcore-mnemonic

But how do I get from the above to be able to use this client side in say chrome without needing the “Require”. Where and how do I generate the bitcore-mnemonic.js client side for use in the browser?

//var Mnemonic = require(‘bitcore-mnemonic’);
var code = new Mnemonic(Mnemonic.Words.SPANISH);
code.toString(); // natal hada sutil año sólido papel jamón combate aula flota ver esfera…
var xpriv = code.toHDPrivateKey();

I am not familiar with node so I do apologize if this something straight forward

Thank you

Ok, Figured it out. Have to be compiled with the standalone flag. Works now



You shouldn’t need to browserify or compile anything if you’re using bower. You just bower install the needed modules, and then include them from the bower_components folder.

Please see this example I just tested and should be working: (for bitcore-ecies, working on a bitcore-mnemonics one now)

@maraoz I am not running this from node. Its a pure client side solution running on a IIS server. I used browserify on index.js to get this to work. Or am I doing this wrongly?

I don’t think I can use the require(‘bitcore’) and require(‘bitcore-ecies’); without node

Yes you can! The linked example is purely client-side code :smile:

Here’s a new mnemonic example:

If you need any help getting this to work, let me know, but it should be as easy as doing:

bower install bitcore
bower install bitcore-mnemonic

and then importing the files form bower_components like so:

sigh… I feel like a fool :blush:

Thanks. that worked.

ps: You wouldn’t happen to have samples on how to retrieve the HDprivate keys from an existing mnemonic seed (bip32) now, would you ?

Btw, I think the sample here is incorrect?

var hdPrivateKey = new HDPrivateKey();
var retrieved = new HDPrivateKey(‘xpriv…’);
var derived = privateKey.derive(“m/0’”); --> var derived = retrieved.derive(“m/0’”);

Yes, it’s wrong. It should either be retrieved or hdPrivateKey