Class DedotClient<ChainApi>

DedotClient

New promised-based API Client for Polkadot & Substrate based on JSON-RPC V2

Unstable, use with caution.

Type Parameters

Hierarchy

Constructors

Properties

_chainHead?: ChainHead
_chainSpec?: ChainSpec
_genesisHash?: `0x${string}`
_localCache?: IStorage
_metadata?: Metadata
_options: ApiOptions
_registry?: PortableRegistry
_runtimeUpgrading?: Deferred<void>
_runtimeVersion?: SubstrateRuntimeVersion
_txBroadcaster?: TxBroadcaster
onConnected: (() => Promise<void>)
onDisconnected: (() => Promise<void>)
onRuntimeUpgrade: ((block: PinnedBlock) => Promise<void>)
rpcVersion: RpcVersion

Accessors

  • get call(): ChainApi["v2"]["call"]
  • Returns ChainApi["v2"]["call"]

  • get chainHead(): ChainHead
  • Returns ChainHead

  • get chainSpec(): ChainSpec
  • Returns ChainSpec

  • get consts(): ChainApi[Rv]["consts"]
  • Returns ChainApi[Rv]["consts"]

  • get currentMetadataKey(): string
  • Returns string

  • get errors(): ChainApi[Rv]["errors"]
  • Returns ChainApi[Rv]["errors"]

  • get events(): ChainApi[Rv]["events"]
  • Returns ChainApi[Rv]["events"]

  • get genesisHash(): `0x${string}`
  • Returns `0x${string}`

  • get metadata(): Metadata
  • Returns Metadata

  • get options(): ApiOptions
  • Returns ApiOptions

  • get provider(): JsonRpcProvider
  • Returns JsonRpcProvider

    Get the JSON-RPC provider instance

  • get query(): ChainApi["v2"]["query"]
  • Returns ChainApi["v2"]["query"]

  • get registry(): PortableRegistry
  • Returns PortableRegistry

  • get rpc(): ChainApi[RpcVersion]["rpc"]
  • Returns ChainApi[RpcVersion]["rpc"]

    Entry-point for executing JSON-RPCs to blockchain node.

    const client = new JsonRpcClient('wss://rpc.polkadot.io');
    await client.connect();

    // Subscribe to new heads
    client.rpc.chain_subscribeNewHeads((header) => {
    console.log(header);
    });

    // Execute arbitrary rpc method: `module_rpc_name`
    const result = await client.rpc.module_rpc_name();
  • get status(): ConnectionStatus
  • Returns ConnectionStatus

    Check connection status of the api instance

  • get tx(): ChainApi["v2"]["tx"]
  • Returns ChainApi["v2"]["tx"]

Methods

  • Returns Promise<void>

  • Returns Promise<void>

  • Parameters

    • OptionalblockHash: `0x${string}`

    Returns ChainApi["v2"]["call"]

  • Returns void

  • Returns Promise<void>

    Clear local cache

  • Returns void

  • Returns Promise<DedotClient<ChainApi>>

    Connect to blockchain node

  • Returns Promise<void>

    Disconnect to blockchain node

  • Initialize APIs before usage

    Returns Promise<void>

  • Returns void

  • Parameters

    Returns boolean

  • Returns Promise<void>

  • Parameters

    Returns Promise<Metadata>

  • Parameters

    Returns undefined | Metadata

  • Parameters

    Returns `RAW_META/${string}`

  • 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>

  • Returns Promise<void>

  • Returns Promise<void>

  • Parameters

    • event: ApiEvent
    • Optionalhandler: HandlerFn

    Returns this

  • Parameters

    Returns Unsub

  • Parameters

    Returns Unsub

  • Parameters

    Returns void

  • Update the signer instance for signing transactions

    Parameters

    • Optionalsigner: Signer

    Returns void

  • Parameters

    Returns Promise<void>

  • Returns Promise<boolean>

  • Returns void

  • Returns void

  • Parameters

    • runtimeVersion: {
          apis: (readonly [`0x${string}`, number])[];
          authoringVersion: number;
          implName: string;
          implVersion: number;
          specName: string;
          specVersion: number;
          stateVersion: number;
          transactionVersion: number;
      }
      • apis: (readonly [`0x${string}`, number])[]
      • authoringVersion: number
      • implName: string
      • implVersion: number
      • specName: string
      • specVersion: number
      • stateVersion: number
      • transactionVersion: number

    Returns SubstrateRuntimeVersion