Interface ISubstrateClient<ChainApi, Events>

A generic interface for Substrate clients

interface ISubstrateClient<ChainApi, Events> {
    atBlockHash?: `0x${string}`;
    call: ChainApi["call"];
    consts: ChainApi["consts"];
    errors: ChainApi["errors"];
    events: ChainApi["events"];
    genesisHash: `0x${string}`;
    metadata: Metadata;
    options: ApiOptions;
    provider: JsonRpcProvider;
    query: ChainApi["query"];
    registry: PortableRegistry;
    rpc: ChainApi["rpc"];
    rpcVersion: RpcVersion;
    runtimeVersion: SubstrateRuntimeVersion;
    status: ConnectionStatus;
    tx: ChainApi["tx"];
    at<ChainApiAt>(hash: `0x${string}`): Promise<ISubstrateClientAt<ChainApiAt>>;
    connect(): Promise<ISubstrateClient<ChainApi, Events>>;
    disconnect(): Promise<void>;
    getRuntimeVersion(): Promise<SubstrateRuntimeVersion>;
    off(event: Events, handler?: HandlerFn): this;
    on(event: Events, handler: HandlerFn): Unsub;
    once(event: Events, handler: HandlerFn): Unsub;
    setSigner(signer?: Signer): void;
}

Type Parameters

Hierarchy (view full)

Properties

atBlockHash?: `0x${string}`
call: ChainApi["call"]
consts: ChainApi["consts"]
errors: ChainApi["errors"]
events: ChainApi["events"]
genesisHash: `0x${string}`
metadata: Metadata
options: ApiOptions
provider: JsonRpcProvider
query: ChainApi["query"]
rpc: ChainApi["rpc"]
rpcVersion: RpcVersion
runtimeVersion: SubstrateRuntimeVersion
tx: ChainApi["tx"]

Methods

  • Get current version of the runtime This is similar to .runtimeVersion but also ensure the corresponding metadata of this runtime version is downloaded & setup.

    This is helpful when you want to check runtime version to prepare for runtime upgrade

    Returns Promise<SubstrateRuntimeVersion>

  • Parameters

    • event: Events
    • Optionalhandler: HandlerFn

    Returns this

  • Parameters

    • event: Events
    • handler: HandlerFn

    Returns Unsub

  • Parameters

    • event: Events
    • handler: HandlerFn

    Returns Unsub

  • Update the signer instance for signing transactions

    Parameters

    • Optionalsigner: Signer

    Returns void