Hierarchy

ApiBase<RxResult, RxResult>

↳ ApiRxInterface

Implements

Implemented by

Constructors

constructor

⊕ new ApiRxInterface(provider?: ApiOptions | ProviderInterface, type: ApiType): ApiRxInterface

Inherited from ApiBase.constructor

Defined in Base.ts:81

description: Create an instance of the class

example:

import Api from '@polkadot/api/promise';

const api = new Api().isReady();

api.rpc.subscribeNewHead((header) => {
  console.log(`new block #${header.blockNumber.toNumber()}`);
});
1
2
3
4
5
6
7

Parameters:

Name Type Default value
Default value provider ApiOptions | ProviderInterface {}
type ApiType -

Returns: ApiRxInterface


Properties

isConnected

● isConnected: Observable<boolean>

Defined in rx/types.ts:13


isReady

● isReady: Observable<ApiRxInterface>

Defined in rx/types.ts:14


Accessors

derive

get derive(): Derive<RxResult, RxResult>

Inherited from ApiBase.derive

Defined in Base.ts:196

description: Derived results that are injected into the API, allowing for combinations of various query results.

example:

api.derive.chain.bestNumber((number) => {
  console.log('best number', number);
});
1
2
3

Returns: Derive<RxResult, RxResult>


genesisHash

get genesisHash(): Hash

Inherited from ApiBase.genesisHash

Defined in Base.ts:132

description: Contains the genesis Hash of the attached chain. Apart from being useful to determine the actual chain, it can also be used to sign immortal transactions.

Returns: Hash


hasSubscriptions

get hasSubscriptions(): boolean

Inherited from ApiBase.hasSubscriptions

Defined in Base.ts:141

description: true when subscriptions are supported

Returns: boolean


libraryInfo

get libraryInfo(): string

Inherited from ApiBase.libraryInfo

Defined in Base.ts:148

description: The library information name & version (from package.json)

Returns: string


query

get query(): QueryableStorage<RxResult, RxResult>

Inherited from ApiBase.query

Defined in Base.ts:216

description: 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.accountNonce(<accountId>) (retrieving the associated nonce for an account), takes the AccountId as a parameter.

example:

api.query.balances.freeBalance(<accountId>, (balance) => {
  console.log('new balance', balance);
});
1
2
3

Returns: QueryableStorage<RxResult, RxResult>


rpc

get rpc(): DecoratedRpc<RxResult, RxResult>

Inherited from ApiBase.rpc

Defined in Base.ts:236

description: 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 (usine known keys) and the submission of transactions.

example:

api.rpc.chain.subscribeNewHead((header) => {
  console.log('new header', header);
});
1
2
3

Returns: DecoratedRpc<RxResult, RxResult>


runtimeMetadata

get runtimeMetadata(): Metadata

Inherited from ApiBase.runtimeMetadata

Defined in Base.ts:155

description: Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.

Returns: Metadata


runtimeVersion

get runtimeVersion(): RuntimeVersion

Inherited from ApiBase.runtimeVersion

Defined in Base.ts:164

description: Contains the version information for the current runtime.

Returns: RuntimeVersion


tx

get tx(): SubmittableExtrinsics<RxResult, RxResult>

Inherited from ApiBase.tx

Defined in Base.ts:254

description: Contains all the extrinsic modules and their subsequent methods in the API. It allows for the construction of transactions and the submission thereof. These are attached dynamically from the runtime metadata.

example:

api.tx.balances
  .transfer(<recipientId>, <balance>)
  .signAndSend(<keyPair>, ({status}) => {
    console.log('tx status', status.asFinalised.toHex());
  });
1
2
3
4
5

Returns: SubmittableExtrinsics<RxResult, RxResult>


type

get type(): ApiType

Inherited from ApiBase.type

Defined in Base.ts:173

description: The type of this API instance, either 'rxjs' or 'promise'

Returns: ApiType


Methods

disconnect

▸ disconnect(): void

Inherited from ApiBase.disconnect

Defined in Base.ts:263

description: Disconnect from the underlying provider, halting all comms

Returns: void


on

▸ on(type: ApiInterface$Events, handler: function): this

Inherited from ApiBase.on

Defined in Base.ts:286

description: Attach an eventemitter handler to listen to a specific event

example:

api.on('connected', () => {
  console.log('API has been connected to the endpoint');
});

api.on('disconnected', () => {
  console.log('API has been disconnected from the endpoint');
});
1
2
3
4
5
6
7

Parameters:

Name Type Description
type ApiInterface$Events The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error`
handler function The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments.

Returns: this


once

▸ once(type: ApiInterface$Events, handler: function): this

Inherited from ApiBase.once

Defined in Base.ts:311

description: Attach an one-time eventemitter handler to listen to a specific event

example:

api.once('connected', () => {
  console.log('API has been connected to the endpoint');
});

api.once('disconnected', () => {
  console.log('API has been disconnected from the endpoint');
});
1
2
3
4
5
6
7

Parameters:

Name Type Description
type ApiInterface$Events The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error`
handler function The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments.

Returns: this


registerTypes

▸ registerTypes(types?: RegistryTypes): void

Inherited from ApiBase.registerTypes

Defined in Base.ts:320

description: Register additional user-defined of chain-specific types in the type registry

Parameters:

Name Type
Optional types RegistryTypes

Returns: void


setSigner

▸ setSigner(signer: Signer): void

Inherited from ApiBase.setSigner

Defined in Base.ts:180

description: Set an external signer which will be used to sign extrinsic when account passed in is not KeyringPair

Parameters:

Name Type
signer Signer

Returns: void


Last Updated: 2/25/2019, 4:39:16 PM