openethereum/js/packages/api
Jaco Greeff a068f72f08 Ui 2 pubsub components (#6152)
* Remove Application.orig from merge

* Disable i18n extraction for development

* Retrieve blockNumber via pubsub

* Chain via pubsub

* StatusIndicator with health

* WIP

* WIP

* s/BlockStatus/BlockNumber/

* Adjust BlockNumber display

* Cleanup debug

* Fix statusbar indicator

* NetPeers component

* Add BlockTimestamp

* Export statics on observer

* Cleanup debug logs

* Update references
2017-07-26 16:54:47 +02:00
..
contract Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
format Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
local Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
provider Ui 2 pubsub components (#6152) 2017-07-26 16:54:47 +02:00
pubsub Merge remote-tracking branch 'origin/ui-2' into ui-2 2017-07-24 16:14:02 +02:00
rpc Merge remote-tracking branch 'origin/ui-2' into ui-2 2017-07-24 16:14:02 +02:00
subscriptions Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
transport Ui 2 pubsub components (#6152) 2017-07-26 16:54:47 +02:00
util Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
api.js Ui 2 pubsub components (#6152) 2017-07-26 16:54:47 +02:00
api.spec.js Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
index.js Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
library.js Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
package.json Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00
README.md Ui 2 move to packages/* (#6113) 2017-07-21 15:46:53 +02:00

@parity/parity.js

Parity.js is a thin, fast, Promise-based wrapper around the Ethereum APIs.

https://github.com/paritytech/parity/tree/master/js/src/api

installation

Install the package with npm install --save @parity/parity.js

usage

initialisation

// import the actual Api class
import { Api } from '@parity/parity.js';

// do the setup
const provider = new Api.Provider.Http('http://localhost:8545');
const api = new Api(provider);

making calls

perform a call

api.eth
  .coinbase()
  .then((coinbase) => {
    console.log(`The coinbase is ${coinbase}`);
  });

multiple promises

Promise
  .all([
    api.eth.coinbase(),
    api.net.listening()
  ])
  .then(([coinbase, listening]) => {
    // do stuff here
  });

chaining promises

api.eth
  .newFilter({...})
  .then((filterId) => api.eth.getFilterChanges(filterId))
  .then((changes) => {
    console.log(changes);
  });

contracts

attach contract

const abi = [{ name: 'callMe', inputs: [{ type: 'bool', ...}, { type: 'string', ...}]}, ...abi...];
const address = '0x123456...9abc';
const contract = new api.newContract(abi, address);

find & call a function

contract.instance
  .callMe
  .call({ gas: 21000 }, [true, 'someString']) // or estimateGas or postTransaction
  .then((result) => {
    console.log(`the result was ${result}`);
  });

apis

APIs implement the calls as exposed in the Ethcore JSON Ethereum RPC definitions. Mapping follows the naming conventions of the originals, i.e. eth_call becomes eth.call, personal_accounts becomes personal.accounts, etc.