Name: js-api
Owner: Parity Technologies
Description: Moved to https://github.com/Parity-JS/api
Created: 2017-07-27 11:30:37.0
Updated: 2018-01-22 09:49:54.0
Pushed: 2018-01-12 12:36:57.0
Homepage: https://github.com/Parity-JS/api
Size: 476
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Parity.js is a thin, fast, Promise-based wrapper around the Ethereum APIs.
Install the package with npm install --save @parity/api
mport the actual Api class
rt Api from '@parity/api';
o the setup
t provider = new Api.Provider.Http('http://localhost:8545');
t api = new Api(provider);
perform a call
eth
oinbase()
hen((coinbase) => {
console.log(`The coinbase is ${coinbase}`);
;
multiple promises
ise
ll([
api.eth.coinbase(),
api.net.listening()
hen(([coinbase, listening]) => {
// do stuff here
;
chaining promises
eth
ewFilter({...})
hen((filterId) => api.eth.getFilterChanges(filterId))
hen((changes) => {
console.log(changes);
;
attach contract
t abi = [{ name: 'callMe', inputs: [{ type: 'bool', ...}, { type: 'string', ...}]}, ...abi...];
t address = '0x123456...9abc';
t contract = api.newContract(abi, address);
find & call a function
ract.instance
allMe
all({ gas: 21000 }, [true, 'someString']) // or estimateGas or postTransaction
hen((result) => {
console.log(`the result was ${result}`);
;
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.
For operation within a public node, the following peerDependencies needs to be added (this functionality will be moved shortly) -