### Install and Run Dapp
Source: https://github.com/dedotdev/dedot/blob/main/examples/dapp/README.md
Instructions for installing and running the example dapp using yarn.
```shell
# From examples/dapp folder
yarn dev
# From the project root folder
yarn workspace dapp dev
```
--------------------------------
### Start the Dapp Application
Source: https://github.com/dedotdev/dedot/blob/main/examples/smoldot-dapp/README.md
Run this command from the examples/dapp folder to start the development server.
```shell
# From examples/dapp folder
yarn dev
```
--------------------------------
### Start the Dapp Application from Project Root
Source: https://github.com/dedotdev/dedot/blob/main/examples/smoldot-dapp/README.md
Run this command from the project root folder to start the development server using yarn workspaces.
```shell
# From the project root folder
yarn workspace dapp dev
```
--------------------------------
### Initialize Smoldot with Web Worker
Source: https://github.com/dedotdev/dedot/blob/main/packages/smoldot/README.md
Demonstrates the setup for using smoldot with a Web Worker. Ensure `@substrate/connect-known-chains` is installed for chain specifications.
```typescript
import { DedotClient, SmoldotProvider } from 'dedot';
import { startWithWorker } from 'dedot/smoldot/with-worker';
import SmoldotWorker from 'dedot/smoldot/worker?worker';
// Initialize smoldot with a worker
const smoldot = startWithWorker(new SmoldotWorker());
// Install `@substrate/connect-known-chains` package to get known-chain specs
const { chainSpec } = await import('@substrate/connect-known-chains/polkadot');
// Add a chain
const chain = smoldot.addChain({ chainSpec });
// Create a provider using the smoldot chain
const provider = new SmoldotProvider(chain);
// Initialize DedotClient with the provider
const client = await DedotClient.new(provider);
// Now you can use the client to interact with the blockchain
```
--------------------------------
### Install Dedot Packages
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/index.html
Install the necessary Dedot packages for your project using npm, yarn, or pnpm.
```bash
npm i dedot # or yarn, pnpm
npm i -D @dedot/chaintypes
```
--------------------------------
### Run ink-node and substrate-contracts-node
Source: https://github.com/dedotdev/dedot/blob/main/e2e/nodes/README.md
Starts both the ink-node and substrate-contracts-node on specified ports. Ensure you are in the download folder before running.
```shell
# cd to the download folder
# run ink-node at port 9955
./ink-node --dev --rpc-port=9955 --state-pruning=archive --blocks-pruning=archive &
# run substrate-contracts-node at port 9944
./substrate-contracts-node --dev --rpc-port=9944 &
```
--------------------------------
### Get Metadata at Version 15
Source: https://github.com/dedotdev/dedot/blob/main/packages/merkleized-metadata/src/__tests__/metadadata/README.md
Use this command to fetch the node's metadata, specifying version 15. Ensure websocat is installed and the RPC endpoint is accessible.
```shell
# Gets the metadata as version 15
echo '{"id":1,"jsonrpc":"2.0","method":"state_call","params":["Metadata_metadata_at_version", "0x0f000000"]}' | websocat -n1 -B 99999999 wss://dot-rpc.stakeworld.io
```
--------------------------------
### Initialize Theme and Log Location
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/types/_dedot_codecs.Text.html
This snippet initializes the theme based on local storage and logs the current location. It's typically used for client-side setup.
```typescript
console.log("Loaded ${location.href}")
document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"
```
--------------------------------
### Querying On-Chain Storage with LegacyClient
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.LegacyClient.html
Access on-chain storage using the query property. This example demonstrates how to retrieve an account's balance.
```typescript
const balance = await api.query.system.account(
);console.log('Balance:', balance);
```
--------------------------------
### Instantiate and Use WsProvider
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_providers.WsProvider.html
Demonstrates how to instantiate WsProvider, connect to a WebSocket endpoint, send a JSON-RPC request to fetch the genesis hash, and subscribe to new block headers. Remember to disconnect when finished.
```typescript
const provider = new WsProvider('wss://rpc.polkadot.io');
await provider.connect();
// Fetch the genesis hash
const genesisHash = await provider.send('chain_getBlockHash', [0]);
console.log(genesisHash);
// Subscribe to runtimeVersion changes
await provider.subscribe(
{
subname: 'chain_newHead',
subscribe: 'chain_subscribeNewHeads',
params: [],
unsubscribe: 'chain_unsubscribeNewHeads',
},
(error, newHead, subscription) => {
console.log('newHead', newHead);
},
);
await provider.disconnect();
```
--------------------------------
### LegacyClient Initialization and Usage
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.LegacyClient.html
Demonstrates how to initialize the LegacyClient and perform common operations like fetching metadata, querying storage, and subscribing to events.
```APIDOC
## LegacyClient Initialization and Usage
### Description
This example shows how to create an instance of `LegacyClient`, connect to a Substrate node, and interact with its API.
### Method
`LegacyClient.new(endpoint: string)`
### Endpoint
N/A (Client-side SDK)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```typescript
import { Dedot } from 'dedot';
import type { PolkadotApi } from '@dedot/chaintypes/polkadot';
const run = async () => {
const api = await LegacyClient.new('wss://rpc.polkadot.io');
// Call rpc `state_getMetadata` to fetch raw scale-encoded metadata and decode it.
const metadata = await api.rpc.state.getMetadata();
console.log('Metadata:', metadata);
// Query on-chain storage
const address = '14...'; // Replace with a valid address
const balance = await api.query.system.account(address);
console.log('Balance:', balance);
// Subscribe to on-chain storage changes
const unsub = await api.query.system.number((blockNumber) => {
console.log(`Current block number: ${blockNumber}`);
});
// Get pallet constants
const ss58Prefix = api.consts.system.ss58Prefix;
console.log('Polkadot ss58Prefix:', ss58Prefix);
// To unsubscribe later:
// await unsub();
// To disconnect:
// await api.disconnect();
};
run().catch(console.error);
```
### Response
#### Success Response (200)
Responses vary based on the methods called (e.g., metadata, storage data, block numbers).
#### Response Example
```json
// Example for metadata:
{
// ... metadata structure ...
}
// Example for balance:
{
// ... balance structure ...
}
```
```
--------------------------------
### connect
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/interfaces/dedot.ISubstrateClient.html
Establishes a connection to the Substrate node.
```APIDOC
## connect(): Promise>
### Description
Establishes a connection to the Substrate node.
### Returns
Promise<[ISubstrateClient](dedot.ISubstrateClient.html)<[ChainApi](dedot.ISubstrateClient.html#ChainApi), [Events](dedot.ISubstrateClient.html#Events)">
Inherited from [IJsonRpcClient](dedot.IJsonRpcClient.html).[connect](dedot.IJsonRpcClient.html#connect)
* Defined in packages/api/dist/types.d.ts:80
```
--------------------------------
### Install Dedot and Chaintypes Packages
Source: https://github.com/dedotdev/dedot/blob/main/README.md
Install the Dedot client and chaintypes packages using npm, yarn, or pnpm. The chaintypes package provides type definitions for specific Polkadot networks.
```shell
npm i dedot # or yarn, pnpm
npm i -D @dedot/chaintypes
```
--------------------------------
### Provider and Client Implementations
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/variables/_dedot_codecs._DisputesTimeSlot.html
Implementations for connecting to Substrate nodes.
```APIDOC
## Classes: Providers and Clients
### Description
Classes for establishing connections and interacting with nodes.
* `WsProvider`: Provides a WebSocket connection to a Substrate node.
* `SmoldotProvider`: Provides a connection using the Smoldot client.
* `JsonRpcClient`: A generic implementation for JSON-RPC clients.
* `LegacyClient`: A client for legacy Substrate APIs.
```
--------------------------------
### get(key)
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_shape.ShapeMap.html
Returns a specified element from the Map object. If the value associated with the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
```APIDOC
## get(key)
### Description
Returns a specified element from the Map object. If the value associated with the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
### Parameters
* **key** (K)
### Returns
undefined | V - The element associated with the specified key, or undefined if the key does not exist.
### Implementation
Implementation of Map.get
```
--------------------------------
### follow
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.ChainHead.html
Starts following the chain head.
```APIDOC
## follow
### Description
Starts following the chain head.
### Method
POST
### Endpoint
/chainHead/follow
### Returns
Promise
```
--------------------------------
### Initialize and Use LegacyClient
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.LegacyClient.html
Demonstrates initializing the LegacyClient with a WebSocket endpoint, fetching metadata, querying account balance, subscribing to block numbers, and accessing constants.
```typescript
import { Dedot } from 'dedot';
import type { PolkadotApi } from '@dedot/chaintypes/polkadot';
const run = async () => {
const api = await LegacyClient.new('wss://rpc.polkadot.io');
// Call rpc `state_getMetadata` to fetch raw scale-encoded metadata and decode it.
const metadata = await api.rpc.state.getMetadata();
console.log('Metadata:', metadata);
// Query on-chain storage
const address = '14...';
const balance = await api.query.system.account(address);
console.log('Balance:', balance);
// Subscribe to on-chain storage changes
const unsub = await api.query.system.number((blockNumber) => {
console.log(`Current block number: ${blockNumber}`);
});
// Get pallet constants
const ss58Prefix = api.consts.system.ss58Prefix;
console.log('Polkadot ss58Prefix:', ss58Prefix)
// await unsub();
// await api.disconnect();
}
run().catch(console.error);
```
--------------------------------
### get
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/interfaces/_dedot_storage.IStorage.html
Retrieves a value from storage by its key.
```APIDOC
## get
### Description
Retrieves a value from storage by its key.
### Method
`get(key: string): Promise`
### Parameters
#### Path Parameters
- **key** (string) - Required - The key of the value to retrieve.
### Response
#### Success Response (200)
- **value** (string | null) - The retrieved value or null if the key does not exist.
#### Response Example
```json
{
"value": "retrieved_value"
}
```
```
--------------------------------
### signedExtensionDef
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.ExtraSignedExtension.html
Gets the definition of the signed extension.
```APIDOC
## signedExtensionDef
### Description
Gets the definition of the signed extension. Inherited from SignedExtension.signedExtensionDef.
### Accessor
`signedExtensionDef(): {
additionalSigned: number;
ident: string;
typeId: number;
}`
### Returns
`{
additionalSigned: number;
ident: string;
typeId: number;
}`
#### Fields
* `additionalSigned` (number)
* `ident` (string)
* `typeId` (number)
```
--------------------------------
### identifier
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.ExtraSignedExtension.html
Gets the identifier for this signed extension.
```APIDOC
## identifier
### Description
Gets the identifier for this signed extension. Overrides SignedExtension.identifier.
### Accessor
`identifier(): string`
### Returns
`string`
```
--------------------------------
### options
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.DedotClient.html
Retrieves the configuration options for the API instance.
```APIDOC
## get options
### Description
Retrieves the configuration options for the API instance.
### Returns
- `ApiOptions`: An object containing the API configuration options.
```
--------------------------------
### JsonRpcClient.provider
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.JsonRpcClient.html
Get the JSON-RPC provider instance.
```APIDOC
## provider
### Description
Get the JSON-RPC provider instance.
### Returns
* [JsonRpcProvider](../interfaces/dedot.JsonRpcProvider.html)
```
--------------------------------
### connect()
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/interfaces/_dedot_api.IJsonRpcClient.html
Establishes a connection to the JSON-RPC provider. Returns a Promise that resolves with the client instance itself upon successful connection.
```APIDOC
## connect()
### Description
Establishes a connection to the JSON-RPC provider.
### Method
connect()
### Returns
Promise<[IJsonRpcClient](_dedot_api.IJsonRpcClient.html)<[ChainApi](_dedot_api.IJsonRpcClient.html#ChainApi), [Events](_dedot_api.IJsonRpcClient.html#Events)">
### Example
```typescript
const client = await jsonRpcClient.connect();
```
```
--------------------------------
### payloadOptions
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.ExtraSignedExtension.html
Gets the payload options for the signed extension.
```APIDOC
## payloadOptions
### Description
Gets the payload options for the signed extension. Inherited from SignedExtension.payloadOptions.
### Accessor
`payloadOptions(): Partial`
### Returns
`Partial`
```
--------------------------------
### connect()
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.SmoldotProvider.html
Establishes a connection to the Smoldot network. This method overrides the base SubscriptionProvider's connect method.
```APIDOC
## connect()
### Description
Establishes a connection to the Smoldot network. This method overrides the base SubscriptionProvider's connect method.
### Returns
Promise
### Overrides
SubscriptionProvider.connect
### Defined in
packages/providers/dist/smoldot/SmoldotProvider.d.ts:12
```
--------------------------------
### connect()
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_providers.WsProvider.html
Establishes a connection using the WebSocket protocol. This method overrides the base SubscriptionProvider's connect method.
```APIDOC
## connect()
### Description
Establishes a WebSocket connection.
### Method
connect
### Returns
Promise
### Example
```typescript
// Assuming an instance of WsProvider is available
await wsProvider.connect();
```
```
--------------------------------
### status
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_providers.WsProvider.html
Gets the current connection status of the provider.
```APIDOC
## status
### Description
Gets the current connection status of the provider.
### Accessor
`get status(): ConnectionStatus`
### Returns
* `ConnectionStatus` - The current connection status.
```
--------------------------------
### get
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/interfaces/_dedot_storage.IStorage.html
Retrieves the value associated with a given key from the storage.
```APIDOC
## get
### Description
Retrieves the value associated with a given key from the storage.
### Method
get(key: string)
### Parameters
#### Path Parameters
- **key** (string) - Description not available
### Returns
Promise
### Defined in
IStorage.ts:5
```
--------------------------------
### connect
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/interfaces/_dedot_api.ISubstrateClient.html
Establishes a connection to the Substrate node, enabling real-time data synchronization and interaction.
```APIDOC
## connect(): Promise>
### Description
Establishes a connection to the Substrate node, enabling real-time data synchronization and interaction.
### Method
`connect`
### Returns
Promise> - A promise that resolves to an ISubstrateClient instance upon successful connection.
```
--------------------------------
### init
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.ExtraSignedExtension.html
Initializes the signed extension. Overrides the base SignedExtension init method.
```APIDOC
## init
### Description
Initializes the signed extension. Overrides SignedExtension.init.
### Method
`init(): Promise`
### Returns
`Promise`
```
--------------------------------
### provider
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.DedotClient.html
Gets the JSON-RPC provider instance used by the client.
```APIDOC
## get provider
### Description
Get the JSON-RPC provider instance.
### Returns
- `JsonRpcProvider`: The JSON-RPC provider instance.
```
--------------------------------
### get(key)
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_storage.LocalStorage.html
Retrieves the value associated with a given key from localStorage.
```APIDOC
## get(key)
### Description
Retrieves the value associated with a given key from localStorage.
### Parameters
* **key** (string) - The key to retrieve.
### Returns
* Promise - The value associated with the key, or null if the key does not exist.
### Example
```typescript
const username = await storage.get('username');
console.log(username); // 'john_doe' or null
```
```
--------------------------------
### DedotClient.new
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.DedotClient.html
Alias for DedotClient.create, providing an alternative way to instantiate the client.
```APIDOC
## DedotClient.new
### Description
Alias for **DedotClient.create**. Factory method to create a new DedotClient instance.
### Method
static new
### Type Parameters
* `ChainApi` extends `VersionedGenericSubstrateApi` = SubstrateApi
### Parameters
* `options`: `ApiOptions` | `JsonRpcProvider`
### Returns
Promise<`DedotClient`<`ChainApi`
### Example
```typescript
const client = await DedotClient.new({
provider: new WebSocketProvider('ws://localhost:9944')
});
```
```
--------------------------------
### atBlockHash Accessor
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.StorageQueryExecutor.html
Gets the block hash at which the storage queries are executed.
```APIDOC
## atBlockHash
### Description
Gets the block hash at which the storage queries are executed.
### Returns
`undefined | `0x${string}``
```
--------------------------------
### WsProvider Constructor
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_providers.WsProvider.html
Initializes a new instance of the WsProvider. It can be initialized with a WebSocket URL string or an options object.
```APIDOC
## constructor
* `new WsProvider(options: string | WsProviderOptions): WsProvider`
### Parameters
* `options` (string | WsProviderOptions) - The WebSocket URL or configuration options for the provider.
### Returns
* `WsProvider` - A new instance of the WsProvider.
```
--------------------------------
### atBlockHash Accessor
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.EventExecutor.html
Gets the block hash associated with the EventExecutor instance.
```APIDOC
## atBlockHash
### Description
Gets the block hash associated with the EventExecutor instance.
### Returns
* `undefined |
`0x${string}
` - The block hash, or undefined if not set.
```
--------------------------------
### DedotClient.create()
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.DedotClient.html
Creates a new instance of DedotClient. This is the primary method for initializing the client.
```APIDOC
## DedotClient.create(options)
### Description
Creates a new instance of DedotClient. This is the primary method for initializing the client.
### Method Signature
`create(options): Promise>`
### Type Parameters
* `ChainApi` extends `VersionedGenericSubstrateApi` = `SubstrateApi`
### Parameters
* `options`: `JsonRpcProvider` | `ApiOptions`
### Returns
* `Promise>`
```
--------------------------------
### SmoldotProvider.status
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.SmoldotProvider.html
Gets the current connection status of the SmoldotProvider. This is an accessor inherited from SubscriptionProvider.
```APIDOC
## status
### Description
Gets the current connection status of the SmoldotProvider.
### Returns
* [ConnectionStatus]
### Inherited from
SubscriptionProvider.status
```
--------------------------------
### Cache and Initialization
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.DedotClient.html
Methods for initializing and managing the local cache, and other initialization tasks.
```APIDOC
## initializeLocalCache()
### Description
Initializes the local cache for storing chain data.
### Method
(Initialization)
### Endpoint
N/A (SDK method)
### Parameters
None
```
```APIDOC
## clearCache()
### Description
Clears the entire local cache.
### Method
(Cache management)
### Endpoint
N/A (SDK method)
### Parameters
None
```
```APIDOC
## initialize(options)
### Description
Initializes the client with the given options.
### Method
(Initialization)
### Endpoint
N/A (SDK method)
### Parameters
* `options`: Initialization options.
```
```APIDOC
## doInitialize(options)
### Description
Performs the internal initialization process.
### Method
(Internal initialization)
### Endpoint
N/A (SDK method)
### Parameters
* `options`: Initialization options.
```
```APIDOC
## normalizeOptions(options)
### Description
Normalizes the provided client options.
### Method
(Utility)
### Endpoint
N/A (SDK method)
### Parameters
* `options`: Client options to normalize.
```
--------------------------------
### Get Transaction Entry-Point
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.LegacyClient.html
Access the transaction entry-point for executing on-chain transactions.
```typescript
api.tx
```
--------------------------------
### Connect to Polkadot Network and Query Data
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/index.html
Connect to the Polkadot network using WsProvider and DedotClient. This example demonstrates fetching metadata, listening to best blocks, querying on-chain storage, accessing constants, and calling runtime APIs.
```typescript
import { DedotClient, WsProvider } from 'dedot';
import type { PolkadotApi } from '@dedot/chaintypes';
const provider = new WsProvider('wss://rpc.polkadot.io');
const client = await DedotClient.new(provider);
// Call rpc `state_getMetadata` to fetch raw scale-encoded metadata and decode it.
const metadata = await client.rpc.state_getMetadata();
console.log('Metadata:', metadata);
// Listen to best blocks
client.chainHead.on('bestBlock', (block: PinnedBlock) => { // or 'finalizedBlock'
console.log(`Current best block number: ${block.number}, hash: ${block.hash}`);
});
// Query on-chain storage
const balance = await client.query.system.account();
console.log('Balance:', balance);
// Get pallet constants
const ss58Prefix = client.consts.system.ss58Prefix;
console.log('Polkadot ss58Prefix:', ss58Prefix);
// Call runtime api
const pendingRewards = await client.call.nominationPoolsApi.pendingRewards()
console.log('Pending rewards:', pendingRewards);
// await unsub();
// await client.disconnect();
```
--------------------------------
### LocalStorage Class
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_storage.LocalStorage.html
Provides methods for setting, getting, and removing items from local storage.
```APIDOC
## Class: LocalStorage
Provides methods for interacting with browser local storage.
### Methods
#### set(key: string, value: any): void
Sets a key-value pair in local storage.
- **key** (string) - The key for the item.
- **value** (any) - The value to store.
#### get(key: string): any | null
Retrieves the value associated with a given key from local storage.
- **key** (string) - The key of the item to retrieve.
Returns the stored value or null if the key is not found.
#### remove(key: string): void
Removes an item from local storage by its key.
- **key** (string) - The key of the item to remove.
#### clear(): void
Clears all items from local storage.
```
--------------------------------
### Run E2E Tests
Source: https://github.com/dedotdev/dedot/blob/main/e2e/nodes/README.md
Executes the end-to-end tests for the e2e-nodes workspace after the nodes have been successfully started.
```shell
yarn workspace e2e-nodes run e2e:test
```
--------------------------------
### PaginationOptions
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/interfaces/_dedot_types.PaginationOptions.html
Defines options for paginating results, including the maximum number of items to return and the starting offset.
```APIDOC
## Interface: PaginationOptions
### Description
An interface for specifying pagination parameters.
### Properties
#### `limit` (number) - Optional
The maximum number of items to return in the response.
#### `offset` (number) - Optional
The number of items to skip from the beginning of the result set.
```
--------------------------------
### LegacyClient Constructor
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.LegacyClient.html
Initializes a new instance of the LegacyClient. It is recommended to use the factory methods `create` or `new` for instantiation.
```APIDOC
## constructor()
### Description
Initializes a new LegacyClient instance.
### Parameters
* **options** (*ApiOptions* | *JsonRpcProvider*) - Configuration options or a JSON RPC provider for the client.
### Type Parameters
* **ChainApi** extends *VersionedGenericSubstrateApi* = *SubstrateApi*
### Returns
* [LegacyClient](_dedot_api.LegacyClient.html)<[ChainApi](_dedot_api.LegacyClient.html#constructor.new_LegacyClient.ChainApi-1)
### Usage
It is recommended to use factory methods like `create` or `new` instead of calling the constructor directly.
```
--------------------------------
### follow
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.ChainHead.html
Starts following chain head updates. Returns a Promise that resolves when the follow operation is initiated.
```APIDOC
## follow
### Description
Starts following chain head updates. Returns a Promise that resolves when the follow operation is initiated.
### Method
`follow()`
### Returns
`Promise`
```
--------------------------------
### LegacyClient.new
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.LegacyClient.html
Initializes a new instance of the LegacyClient, connecting to a specified WebSocket endpoint. It allows for interaction with Substrate-based networks.
```APIDOC
## new(endpoint: string, options?: BaseClientOptions): Promise>
### Description
Initializes a new instance of the LegacyClient, connecting to a specified WebSocket endpoint. It allows for interaction with Substrate-based networks.
### Method
`new` (static method)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
* **endpoint** (string) - Required - The WebSocket endpoint URL of the Substrate node.
* **options** (BaseClientOptions) - Optional - Configuration options for the client.
### Response
#### Success Response
- **Promise>** - A promise that resolves to a new LegacyClient instance.
### Request Example
```typescript
import { LegacyClient } from '@dedot/api';
import type { PolkadotApi } from '@dedot/chaintypes/polkadot';
const api = await LegacyClient.new('wss://rpc.polkadot.io');
```
```
--------------------------------
### create
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/dedot.DedotClient.html
Factory method to create a new DedotClient instance with specified options.
```APIDOC
## create
### Description
Factory method to create a new DedotClient instance.
### Type Parameters
* **ChainApi** extends `VersionedGenericSubstrateApi` = `SubstrateApi`
### Parameters
* **options**: `JsonRpcProvider` | `ApiOptions` - The options for creating the client.
### Returns
* **Promise>**: A promise that resolves to a new DedotClient instance.
```
--------------------------------
### at
Source: https://github.com/dedotdev/dedot/blob/main/typedoc/classes/_dedot_api.DedotClient.html
Get a new API instance at a specific block hash. For now, this only supports pinned block hashes from the chain head.
```APIDOC
## at(hash: `0x${string}`)
### Description
Get a new API instance at a specific block hash. For now, this only supports pinned block hashes from the chain head.
### Parameters
#### Path Parameters
- **hash** (`0x${string}`) - Description not available
### Returns
Promise<[ISubstrateClientAt](../interfaces/_dedot_api.ISubstrateClientAt.html)<[ChainApiAt](_dedot_api.DedotClient.html#at.at-1.ChainApiAt)">
### Type Parameters
* ChainApiAt extends [GenericSubstrateApi](../interfaces/_dedot_types.GenericSubstrateApi.html)<[RpcVersion](../types/_dedot_types.RpcVersion.html)"> = [ChainApi](_dedot_api.DedotClient.html#constructor.new_DedotClient.ChainApi-1)["v2"]
```