Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including web4js with all npm packages installed. Try it out:

var web4js = require("web4js")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

web4js v0.20.9

Theos & Hyperdapp JavaScript API, middleware to talk to a theos node over RPC

Hyperdapp & Theos JavaScript API

Join the chat at

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.

NPM version Build Status dependency status dev dependency status Coverage Status Stories in Ready

You need to run a local Ethereum node to use this library.


Table of Contents



npm install web4js


yarn add web4js


meteor add hyperdapp:web4js

As a Browser module


<script src="" integrity="sha256-nWBTbvxhJgjslRyuAKJHK+XcZPlCnmIAAMixz6EefVk=" crossorigin="anonymous"></script>


bower install web4js


component install hyperdapp/web4.js
  • Include web4.min.js in your html file. (not required for the meteor package)


Use the web4 object directly from the global namespace:

console.log(web4); // {eth: .., shh: ...} // It's here!

Set a provider (HttpProvider):

if (typeof web4 !== 'undefined') {
  web4 = new web4(web4.currentProvider);
} else {
  // Set the provider you want from web4.providers
  web4 = new web4(new web4.providers.HttpProvider("http://localhost:8545"));

Set a provider (HttpProvider using HTTP Basic Authentication):

web4.setProvider(new web4.providers.HttpProvider('http://' + BasicAuthUsername + ':' + BasicAuthPassword + '@localhost:8545'));

There you go, now you can use it:

var coinbase = web4.eth.coinbase;
var balance = web4.eth.getBalance(coinbase);

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;



  • Node.js
  • npm
# On Linux:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install nodejs-legacy

Building (gulp)

npm run-script build

Testing (mocha)

npm test


Other upcoming implementations


MIT © 2018 Contributors

LGPL-3.0+ © 2015 Contributors For any omissions, please contact us at

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free