DedotClient
DedotClient
interface DedotClient<ChainApi> {
// Connection
status: ConnectionStatus; // Current connection status
connect(): Promise<this>; // Connect to the network
disconnect(): Promise<void>; // Disconnect from the network
// Chain Information
genesisHash: Hash; // Genesis hash of the connected chain
runtimeVersion: SubstrateRuntimeVersion; // Current runtime version
metadata: Metadata; // Chain metadata
registry: PortableRegistry; // Type registry for encoding/decoding
// Chain Spec
chainSpec: {
chainName(): Promise<string>; // Get chain name
genesisHash(): Promise<HexString>; // Get genesis hash
properties(): Promise<Properties>; // Get chain properties (token symbol, decimals, etc.)
};
// Block Explorer
block: {
best(): Promise<BlockInfo>; // Get current best block
best(callback: (block: BlockInfo) => void): () => void; // Subscribe to best blocks
finalized(): Promise<BlockInfo>; // Get current finalized block
finalized(callback: (block: BlockInfo) => void): () => void; // Subscribe to finalized blocks
header(hash: BlockHash): Promise<Header>; // Get block header
body(hash: BlockHash): Promise<HexString[]>; // Get block body (extrinsics)
};
// On-chain Interactions
rpc: ChainApi['rpc']; // Raw JSON-RPC method access
query: ChainApi['query']; // Storage queries
consts: ChainApi['consts']; // Pallet constants
call: ChainApi['call']; // Runtime API calls
tx: ChainApi['tx']; // Transaction builder
events: ChainApi['events']; // Events API
errors: ChainApi['errors']; // Errors API
view: ChainApi['view']; // View functions (Metadata V16+)
// Utilities
at(hash: BlockHash): Promise<ISubstrateClientAt>; // Get an instance at a specific block for querying historical state
getRuntimeVersion(): Promise<SubstrateRuntimeVersion>; // Get runtime version with metadata sync
setSigner(signer?: InjectedSigner): void; // Set transaction signer
sendTx(tx: HexString | Extrinsic, callback?: Callback): TxUnsub; // Broadcast transaction
queryMulti(queries: Query[], callback?: Callback): Promise<any[]>; // Query multiple storage items
// Events
on(event: ApiEvent, handler: EventHandlerFn): () => void; // Subscribe to client events
once(event: ApiEvent, handler: EventHandlerFn): () => void; // Subscribe once
off(event: ApiEvent, handler?: EventHandlerFn): this; // Unsubscribe
}Connect to network via legacy JSON-RPC APIs
JsonRpcClient (Advanced)
Connection Status
Status
Description
Block Explorer API (client.block)
client.block)Property
Type
Description
Chain Spec API (client.chainSpec)
client.chainSpec)Broadcast Transaction API (client.sendTx)
client.sendTx)Client Events
DedotClientOptions
Option
Type
Default
Description
Last updated