@@ -51,16 +51,33 @@ From the repo:
51
51
52
52
### Browser
53
53
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.
55
56
56
- $ npm run-script compile
57
+ [ Browserify ] ( https://github.com/substack/node-browserify ) is assumed to be installed for these steps.
57
58
58
- From NPM:
59
59
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
62
61
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.
64
81
65
82
66
83
## Examples
0 commit comments