Optionaloptions: ApiOptions
Options to create an instance. This can be either [[ApiOptions]] or an [[WsProvider]].
Protected__Protected_Protected_Protected_This is the one and only method concrete children classes need to implement.
It's a higher-order function, which takes one argument
method: Method extends (...args: any[]) => Observable<any>
(and one optional options), and should return the user facing method.
For example:
decorateMethod should just be identity, because the input
function is already an ObservabledecorateMethod should return a function that takes all
the parameters from method, adds an optional callback argument, and
returns a Promise.We could easily imagine other user-facing interfaces, which are simply
implemented by transforming the Observable to Stream/Iterator/Kefir/Bacon
via decorateMethod.
Protected Optional_Protected_Protected_Protected Optional_Protected_Protected Optional_Protected_Protected_Protected Readonly_Protected_Protected Optional_Protected Optional_Protected_Protected Optional_Protected_Protected Optional_Protected Optional_Protected_Protected_true if the API operates with subscriptions
Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
All calls inside the namespace, is denoted by section.method and may take an optional query parameter. As an example, api.query.timestamp.now() (current block timestamp) does not take parameters, while api.query.system.account(<accountId>) (retrieving the associated nonce & balances for an account), takes the AccountId as a parameter.
Allows for the querying of multiple storage entries and the combination thereof into a single result. This is a very optimal way to make multiple queries since it only makes a single connection to the node and retrieves the data over one subscription.
const unsub = await api.queryMulti(
[
// you can include the storage without any parameters
api.query.balances.totalIssuance,
// or you can pass parameters to the storage query
[api.query.system.account, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY']
],
([existential, [, { free }]]) => {
console.log(`You have ${free.sub(existential)} more than the existential deposit`);
unsub();
}
);
Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions. Unlike the dynamic api.query and api.tx sections, these methods are fixed (although extensible with node upgrades) and not determined by the runtime.
RPC endpoints available here allow for the query of chain, node and system information, in addition to providing interfaces for the raw queries of state (using known keys) and the submission of transactions.
true if the API decorate multi-key queries
Protected_Optionaladditional: DefinitionsCallProtected_OptionalblockHash: Uint8ArrayProtected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_OptionalblockHash: Uint8ArrayProtected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_An array of function to combine, each in the form of (cb: (value: void)) => void
A callback that will return an Array of all the values this combinator has been applied to
Creates a combinator that can be used to combine the latest results from multiple subscriptions
const address = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFacT7';
// combines values from balance & nonce as it updates
api.combineLatest([
api.rpc.chain.subscribeNewHeads,
(cb) => api.query.system.account(address, cb)
], ([head, [balance, nonce]]) => {
console.log(`#${head.number}: You have ${balance.free} units, with ${nonce} transactions sent`);
});
ProtectedemitOptionalfromEmpty: booleanOptionalregistry: RegistryThe type of event the callback was attached to. Available events are connected, disconnected, ready and error
The callback to unregister.
The type of event to listen to. Available events are connected, disconnected, ready and error
The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments.
The type of event to listen to. Available events are connected, disconnected, ready and error
The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments.
StaticcreateOptionaloptions: ApiOptions
options that is passed to the class contructor. Can be either [[ApiOptions]] or a provider (see the constructor arguments)
@pezkuwi/api/promise
Overview
Name
ApiPromise
Description
ApiPromise is a standard JavaScript wrapper around the RPC and interfaces on the Pezkuwi network. As a full Promise-based, all interface calls return Promises, including the static
.create(...). Subscription calls utilise(value) => {}callbacks to pass through the latest values.The API is well suited to real-time applications where either the single-shot state is needed or use is to be made of the subscription-based features of Pezkuwi (and Bizinikiwi) clients.
See
[[ApiRx]]
Usage
Making rpc calls -
Subscribing to chain state -
Submitting a transaction -