Skip to content

README: improve browser setup advice #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,38 @@ If you are looking for the original, it is tagged as `0.1.3`. Unless you need it

var bitcoin = require('bitcoinjs-lib')

From the repo:

var bitcoin = require('./src/index.js')
### Browser

If you're familiar with how to use browserify, ignore this and proceed normally.
These steps are advisory only and allow you to use the API to its full extent.

### Browser
[Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps.

From your repository, create a `foobar.js` file

``` javascript
var foobar = {
base58: require('bs58'),
bitcoin: require('bitcoinjs-lib'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will complain that bitcoinjs-lib is not found as it has not yet been installed through npm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with bs58, and any others.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So? the instruction is still incomplete

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it has been installed.

This is under the ## Setup header, with ## Installation above it.
Therefore, at this stage, it is assumed they have bitcoinjs-lib installed.

ecurve: require('ecurve'),
BigInteger: require('bigi'),
Buffer: require('buffer')
}

module.exports = foobar
```

From the repository: Compile `bitcoinjs-min.js` with the following command:
Each of these included packages are seperate to `bitcoinjs-lib`, and must be installed separately.
They are however used in the bitcoinjs-lib public API.

$ npm run-script compile
Using browserify, compile `foobar.js` for use in the browser:

From NPM:
$ browserify foobar.js -s foobar > foobar.js

$ npm -g install bitcoinjs-lib browserify uglify-js
$ browserify -r bitcoinjs-lib -s bitcoin | uglifyjs > bitcoinjs.min.js
You will then be able to load `foobar.js` into your browser, with each of the dependencies above accessible from the global `foobar` object.

After loading this file in your browser, you will be able to use the global `bitcoin` object.
**NOTE**: See our package.json for the currently supported version of browserify used by this repository.


## Examples
Expand Down