15 KiB
Type parameters
EventTypes : string | symbol
Hierarchy
↳ ApiBase<RpcRx, QueryableStorage, SubmittableExtrinsics>
↳ ApiRx
Implements
Constructors
constructor
⊕ new ApiRx(wsProvider?: WsProvider): ApiRx
Overrides ApiBase.constructor
Defined in rx/index.ts:44
example:
import Api from '@polkadot/api/rx';
new Api().isReady.subscribe((api) => {
api.rpc.newHead().subscribe((header) => {
console.log(`new block #${header.blockNumber.toNumber()}`);
});
});
Parameters:
| Param | Type | Description |
|---|---|---|
Optional wsProvider |
WsProvider |
An optional WebSocket provider from rpc-provider/ws. If not specified, it will default to connecting to the localhost with the default port |
Returns: ApiRx
Properties
<Protected>``<Optional> _extrinsics
● _extrinsics: E
Inherited from ApiBase._extrinsics
Defined in Base.ts:33
<Protected>``<Optional> _genesisHash
● _genesisHash: Hash
Inherited from ApiBase._genesisHash
Defined in Base.ts:34
<Protected> _rpc
● _rpc: RpcRx
Defined in Base.ts:36
<Protected> _rpcBase
● _rpcBase: Rpc
Inherited from ApiBase._rpcBase
Defined in Base.ts:37
<Protected>``<Optional> _runtimeMetadata
● _runtimeMetadata: RuntimeMetadata
Inherited from ApiBase._runtimeMetadata
Defined in Base.ts:38
<Protected>``<Optional> _runtimeVersion
● _runtimeVersion: RuntimeVersion
Inherited from ApiBase._runtimeVersion
Defined in Base.ts:39
<Protected>``<Optional> _storage
● _storage: S
Inherited from ApiBase._storage
Defined in Base.ts:35
<Static> prefixed
● prefixed: * string | boolean
*
Inherited from EventEmitter.prefixed
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:6
Accessors
genesisHash
getgenesisHash(): Hash
Inherited from ApiBase.genesisHash
Defined in Base.ts:68
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
isConnected
getisConnected(): Observable<boolean>
Defined in rx/index.ts:77
description: Observable that carries the connected state for the provider. Results in a boolean flag that is true/false based on the connectivity.
Returns: Observable<boolean>
isReady
getisReady(): Observable<ApiRx>
Defined in rx/index.ts:84
description: Observable that returns the first time we are connected and loaded
Returns: Observable<ApiRx>
rpc
getrpc(): RpcRx
Defined in Base.ts:105
description: Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions.
example:
api.rpc.chain
.newHead()
.subscribe((header) => {
console.log('new header', header);
});
Returns: RpcRx
runtimeMetadata
getruntimeMetadata(): RuntimeMetadata
Inherited from ApiBase.runtimeMetadata
Defined in Base.ts:77
description: Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.
Returns: RuntimeMetadata
runtimeVersion
getruntimeVersion(): RuntimeVersion
Inherited from ApiBase.runtimeVersion
Defined in Base.ts:86
description: Contains the version information for the current runtime.
Returns: RuntimeVersion
st
getst(): QueryableStorage
Defined in Base.ts:122
description: Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
example:
api.st.balances
.freeBalance(<accountId>)
.subscribe((balance) => {
console.log('new balance', balance);
});
Returns: QueryableStorage
tx
gettx(): SubmittableExtrinsics
Defined in Base.ts:143
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>)
.sign(<keyPair>, <accountNonce>, <blockHash (optional)>)
.send()
.subscribe((status) => {
console.log('tx status', status);
});
Returns: SubmittableExtrinsics
Methods
addListener
▸ addListener(event: EventTypes, fn: ListenerFn, context?: any): this
Inherited from EventEmitter.addListener
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:33
Parameters:
| Param | Type |
|---|---|
| event | EventTypes |
| fn | ListenerFn |
Optional context |
any |
Returns: this
<Protected> decorateExtrinsics
▸ decorateExtrinsics(extrinsics: Extrinsics): SubmittableExtrinsics
Overrides ApiBase.decorateExtrinsics
Defined in rx/index.ts:92
Parameters:
| Param | Type |
|---|---|
| extrinsics | Extrinsics |
Returns: SubmittableExtrinsics
<Protected> decorateFunctionMeta
▸ decorateFunctionMeta(input: MetaDecoration, output: MetaDecoration): MetaDecoration
Inherited from ApiBase.decorateFunctionMeta
Defined in Base.ts:200
Parameters:
| Param | Type |
|---|---|
| input | MetaDecoration |
| output | MetaDecoration |
Returns: MetaDecoration
<Protected> decorateRpc
▸ decorateRpc(rpc: Rpc): RpcRx
Overrides ApiBase.decorateRpc
Defined in rx/index.ts:88
Parameters:
| Param | Type |
|---|---|
| rpc | Rpc |
Returns: RpcRx
<Protected> decorateStorage
▸ decorateStorage(storage: Storage): QueryableStorage
Overrides ApiBase.decorateStorage
Defined in rx/index.ts:113
Parameters:
| Param | Type |
|---|---|
| storage | Storage |
Returns: QueryableStorage
emit
▸ emit(event: EventTypes, ...args: Array<any>): boolean
Inherited from EventEmitter.emit
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:27
Calls each of the listeners registered for a given event.
Parameters:
| Param | Type |
|---|---|
| event | EventTypes |
Rest args |
Array<any> |
Returns: boolean
eventNames
▸ eventNames(): Array<EventTypes>
Inherited from EventEmitter.eventNames
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:12
Return an array listing the events for which the emitter has registered listeners.
Returns: Array<EventTypes>
listenerCount
▸ listenerCount(event: EventTypes): number
Inherited from EventEmitter.listenerCount
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:22
Return the number of listeners listening to a given event.
Parameters:
| Param | Type |
|---|---|
| event | EventTypes |
Returns: number
listeners
▸ listeners(event: EventTypes): Array<ListenerFn>
Inherited from EventEmitter.listeners
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:17
Return the listeners registered for a given event.
Parameters:
| Param | Type |
|---|---|
| event | EventTypes |
Returns: Array<ListenerFn>
off
▸ off(event: EventTypes, fn?: ListenerFn, context?: any, once?: * undefined | false | true*): this
Inherited from EventEmitter.off
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:44
Parameters:
| Param | Type |
|---|---|
| event | EventTypes |
Optional fn |
ListenerFn |
Optional context |
any |
Optional once |
undefined | false | true |
Returns: this
on
▸ on(event: EventTypes, fn: ListenerFn, context?: any): this
Inherited from EventEmitter.on
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:32
Add a listener for a given event.
Parameters:
| Param | Type |
|---|---|
| event | EventTypes |
| fn | ListenerFn |
Optional context |
any |
Returns: this
once
▸ once(event: EventTypes, fn: ListenerFn, context?: any): this
Inherited from EventEmitter.once
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:38
Add a one-time listener for a given event.
Parameters:
| Param | Type |
|---|---|
| event | EventTypes |
| fn | ListenerFn |
Optional context |
any |
Returns: this
removeAllListeners
▸ removeAllListeners(event?: EventTypes): this
Inherited from EventEmitter.removeAllListeners
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:49
Remove all listeners, or those of the specified event.
Parameters:
| Param | Type |
|---|---|
Optional event |
EventTypes |
Returns: this
removeListener
▸ removeListener(event: EventTypes, fn?: ListenerFn, context?: any, once?: * undefined | false | true*): this
Inherited from EventEmitter.removeListener
Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:43
Remove the listeners of a given event.
Parameters:
| Param | Type |
|---|---|
| event | EventTypes |
Optional fn |
ListenerFn |
Optional context |
any |
Optional once |
undefined | false | true |
Returns: this
<Static> create
▸ create(wsProvider?: WsProvider): Observable<ApiRx>
Defined in rx/index.ts:42
description: Creates an ApiRx instance using the supplied provider. Returns an Observable containing the actual Api instance.
example:
import Api from '@polkadot/api/rx';
Api.create().subscribe((api) => {
api.st.timestamp.now((timestamp) => {
console.log(`lastest block timestamp ${timestamp}`);
});
});
Parameters:
| Param | Type | Description |
|---|---|---|
Optional wsProvider |
WsProvider |
Optional WebSocket provider that is passed to the class contructor |
Returns: Observable<ApiRx>