• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

parity-js/api: Moved to https://github.com/paritytech/js-libs/tree/master/packag ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

parity-js/api

开源软件地址:

https://github.com/parity-js/api

开源编程语言:

JavaScript 99.7%

开源软件介绍:

IMPORTANT

This repository is not maintained anymore. It has been moved to https://github.com/paritytech/js-libs/tree/master/packages/api.

@parity/api

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

Build Status Coverage Status Dependency Status devDependency Status

installation

Install the package with npm install --save @parity/api

usage

initialisation

// import the actual Api class
import Api from '@parity/api';

// 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 = 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.

public node

For operation within a public node, the following peerDependencies needs to be added (this functionality will be moved shortly) -




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap