Hyperdapp & Theos JavaScript API
This is the Ethereum compatible JavaScript API which implements the Generic JSON RPC spec. It's available on npm as a node module, for Bower and component as embeddable scripts, and as a meteor.js package.
You need to run a local Ethereum node to use this library.
Table of Contents
Installation
Node.js
npm install web4js
Yarn
yarn add web4js
Meteor.js
meteor add hyperdapp:web4js
As a Browser module
CDN
Bower
bower install web4js
Component
component install hyperdapp/web4.js
- Include
web4.min.js
in your html file. (not required for the meteor package)
Usage
Use the web4
object directly from the global namespace:
console; // {eth: .., shh: ...} // It's here!
Set a provider (HttpProvider
):
if typeof web4 !== 'undefined' web4 = web4currentProvider; else // Set the provider you want from web4.providers web4 = "http://localhost:8545";
Set a provider (HttpProvider
using HTTP Basic Authentication):
web4;
There you go, now you can use it:
var coinbase = web4ethcoinbase;var balance = web4eth;
You can find more examples in the example
directory.
Migration from web3 to web4
web4.js is derived from web3.js of Ethereum web3 . To migrate to this framework, please follow the guide:
+Run/Connect to Theos Blockchain;
+Deploy Smart Contract;
+Install Smart Contract on Hyperdapp;
Contribute!
Requirements
- Node.js
- npm
# On Linux: sudo apt-get updatesudo apt-get install nodejssudo apt-get install npmsudo apt-get install nodejs-legacy
Building (gulp)
npm run-script build
Testing (mocha)
npm test
Community
Other upcoming implementations
- Python web4.py
License
MIT © 2018 Contributors
LGPL-3.0+ © 2015 Contributors For any omissions, please contact us at info@hyperdapp.org