updated README.md

This commit is contained in:
Marek Kotewicz 2015-07-13 15:58:38 +02:00
parent 4583998bfb
commit d7dd92169b

View File

@ -17,40 +17,52 @@ You need to run a local ethrereum node to use this library.
### Node.js ### Node.js
$ npm install web3 ```bash
npm install web3
```
### Meteor.js ### Meteor.js
$ meteor add ethereum:web3 ```bash
meteor add ethereum:web3
```
### As Browser module ### As Browser module
Bower Bower
$ bower install web3 ```bash
bower install web3
```
Component Component
$ component install ethereum/web3.js ```bash
component install ethereum/web3.js
```
* Include `ethereum.min.js` in your html file. (not required for the meteor package) * Include `ethereum.min.js` in your html file. (not required for the meteor package)
## Usage ## Usage
Use the `web3` object directly from global namespace: Use the `web3` object directly from global namespace:
console.log(web3); // {eth: .., shh: ...} // it's here! ```js
console.log(web3); // {eth: .., shh: ...} // it's here!
```
Set a provider (HttpProvider) Set a provider (HttpProvider)
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')); ```js
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
```
There you go, now you can use it: There you go, now you can use it:
``` ```js
var coinbase = web3.eth.coinbase; var coinbase = web3.eth.coinbase;
var balance = web3.eth.getBalance(coinbase); var balance = web3.eth.getBalance(coinbase);
``` ```
For another example see `example/index.html`. You can find more examples in [`example`](https://github.com/ethereum/web3.js/tree/master/example) directory.
## Contribute! ## Contribute!