Skip to content

Commit 7ee8a85

Browse files
committed
README: improve browserify instructions
1 parent abf870f commit 7ee8a85

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,33 @@ From the repo:
5151

5252
### Browser
5353

54-
From the repository: Compile `bitcoinjs-min.js` with the following command:
54+
If you're familiar with how to use browserify, ignore this and proceed normally.
55+
These steps are advisory only and allow you to use the API to its full extent.
5556

56-
$ npm run-script compile
57+
[Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps.
5758

58-
From NPM:
5959

60-
$ npm -g install bitcoinjs-lib browserify uglify-js
61-
$ browserify -r bitcoinjs-lib -s bitcoin | uglifyjs > bitcoinjs.min.js
60+
From your repository, create a `bitcoin.js` file
6261

63-
After loading this file in your browser, you will be able to use the global `bitcoin` object.
62+
``` javascript
63+
var bitcoin = {
64+
base58: require('bs58'),
65+
ecurve: require('ecurve'),
66+
BigInteger: require('bigi'),
67+
Buffer: require('buffer')
68+
}
69+
70+
var bitcoinjs = require('bitcoinjs-lib')
71+
for (var a in bitcoinjs) bitcoin[a] = bitcoinjs[a]
72+
73+
module.exports = bitcoin
74+
```
75+
76+
Then, using browserify, compile `bitcoin.js` for use in the browser:
77+
78+
$ browserify bitcoin.js -s bitcoin > dist/bitcoin.js
79+
80+
You will then be able to load `dist/bitcoin.js` into your browser, with each of the dependencies above accessible from the global `bitcoin` object.
6481

6582

6683
## Examples

0 commit comments

Comments
 (0)