在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:parity-js/api开源软件地址:https://github.com/parity-js/api开源编程语言:JavaScript 99.7%开源软件介绍:IMPORTANTThis repository is not maintained anymore. It has been moved to https://github.com/paritytech/js-libs/tree/master/packages/api. @parity/apiParity.js is a thin, fast, Promise-based wrapper around the Ethereum APIs. installationInstall the package with usageinitialisation// 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 callsperform 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);
}); contractsattach 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}`);
}); apisAPIs implement the calls as exposed in the Ethcore JSON Ethereum RPC definitions. Mapping follows the naming conventions of the originals, i.e. public nodeFor operation within a public node, the following peerDependencies needs to be added (this functionality will be moved shortly) - |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论