https://github.com/crypto-artisan/web3js
https://github.com/crypto-artisan/web3js
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/crypto-artisan/web3js
- Owner: crypto-artisan
- License: other
- Created: 2024-01-04T12:08:08.000Z (over 1 year ago)
- Default Branch: 1.x
- Last Pushed: 2024-01-04T12:43:06.000Z (over 1 year ago)
- Last Synced: 2025-01-19T22:22:49.448Z (4 months ago)
- Language: JavaScript
- Size: 36 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
# web3.js - Ethereum JavaScript API
[](https://gitter.im/ethereum/web3.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[](https://www.npmjs.com/package/web3) [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url] [![Coverage Status][coveralls-image]][coveralls-url]
This is the Ethereum [JavaScript API][docs]
which connects to the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) spec.You need to run a local or remote [Ethereum](https://www.ethereum.org/) node to use this library.
Please read the [documentation][docs] for more.
## Installation
### Node
```bash
npm install web3
```### Yarn
```bash
yarn add web3
```### Meteor
*Note*: works only in the Browser for now. (PR welcome).
```bash
meteor add ethereum:web3
```### In the Browser
Use the prebuild ``dist/web3.min.js``, or
build using the [web3.js][repo] repository:```bash
npm run-script build
```Then include `dist/web3.js` in your html file.
This will expose `Web3` on the window object.## Usage
```js
// in node.js
var Web3 = require('web3');var web3 = new Web3('ws://localhost:8546');
console.log(web3);
> {
eth: ... ,
shh: ... ,
utils: ...,
...
}
```Additionally you can set a provider using `web3.setProvider()` (e.g. WebsocketProvider):
```js
web3.setProvider('ws://localhost:8546');
// or
web3.setProvider(new Web3.providers.WebsocketProvider('ws://localhost:8546'));
```There you go, now you can use it:
```js
web3.eth.getAccounts()
.then(console.log);
```### Usage with TypeScript
Type definitions are maintained at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) by others. You can install them with:
```bash
npm install --dev @types/web3.js
```You might need to install type definitions for `bignumber.js` and `lodash` too.
And then use `web3.js` as follows:
```typescript
import Web3 = require("web3"); // Note the special syntax! Copy this line when in doubt!
const web3 = new Web3("ws://localhost:8546");
```**Please note:** We do not support TypeScript ourselves. If you have any issue with TypeScript and `web3.js` do not create an issue here. Go over to DefinitelyTyped and do it there.
## Documentation
Documentation can be found at [read the docs][docs].
## Building
### Requirements
* [Node.js](https://nodejs.org)
* [npm](https://www.npmjs.com/)```bash
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
```### Building (gulp)
Build only the web3.js package
```bash
npm run-script build
```Or build all sub packages as well:
```bash
npm run-script build-all
```This will put all the browser build files into the `dist` folder.
### Testing (mocha)
```bash
npm test
```### Contributing
- All contributions have to go into develop, or the 1.0 branch
- Please follow the code style of the other files, we use 4 spaces as tabs.### Community
- [Gitter](https://gitter.im/ethereum/web3.js?source=orgpage)
- [Forum](https://forum.ethereum.org/categories/ethereum-js)### Similar libraries in other languages
- Python - [Web3.py](https://github.com/pipermerriam/web3.py)
- Haskell - [hs-web3](https://github.com/airalab/hs-web3)
- Java - [web3j](https://github.com/web3j/web3j)
- Scala - [web3j-scala](https://github.com/mslinn/web3j-scala)
- Purescript - [purescript-web3](https://github.com/f-o-a-m/purescript-web3)
- PHP - [web3.php](https://github.com/sc0Vu/web3.php)[repo]: https://github.com/ethereum/web3.js
[docs]: http://web3js.readthedocs.io/
[npm-image]: https://badge.fury.io/js/web3.png
[npm-url]: https://npmjs.org/package/web3
[travis-image]: https://travis-ci.org/ethereum/web3.js.svg
[travis-url]: https://travis-ci.org/ethereum/web3.js
[dep-image]: https://david-dm.org/ethereum/web3.js.svg
[dep-url]: https://david-dm.org/ethereum/web3.js
[dep-dev-image]: https://david-dm.org/ethereum/web3.js/dev-status.svg
[dep-dev-url]: https://david-dm.org/ethereum/web3.js#info=devDependencies
[coveralls-image]: https://coveralls.io/repos/ethereum/web3.js/badge.svg?branch=master
[coveralls-url]: https://coveralls.io/r/ethereum/web3.js?branch=1.x
[waffle-image]: https://badge.waffle.io/ethereum/web3.js.svg?label=ready&title=Ready
[waffle-url]: https://waffle.io/ethereum/web3.js