@dedot/chaintypes

中文文档
0.280.0发布于 2026/05/09Apache-2.0TypeScriptES Module零依赖近 30 天下载 3224

Types for substrate-based chains

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Initializing DedotClient with ChainTypes
  4. Examples for Different Networks
  5. Supported Networks
  6. License

@dedot/chaintypes

TypeScript definitions for various PolkadotSDK-based known networks.

Installation

# Install dedot
npm i dedot

# Install chaintypes as a dev dependency
npm i -D @dedot/chaintypes

Note: @dedot/chaintypes should be installed as a dev dependency since it only provides TypeScript type definitions for known-chains and is not needed at runtime.

Usage

Import types for specific networks:

// Import types for Polkadot
import type { PolkadotApi } from '@dedot/chaintypes';

// Import types for Kusama
import type { KusamaApi } from '@dedot/chaintypes';

// Import types for other networks
import type { 
  AstarApi,
  MoonbeamApi,
  // ... other networks
} from '@dedot/chaintypes';

You can also import types for specific networks directly:

// Import types for Polkadot directly
import type { PolkadotApi } from '@dedot/chaintypes/polkadot';

Initializing DedotClient with ChainTypes

To get full TypeScript support when working with a specific network, you can initialize a DedotClient with the appropriate ChainApi:

import { DedotClient, WsProvider } from 'dedot';
import type { PolkadotApi } from '@dedot/chaintypes';

// Initialize a typed client for Polkadot
const client = await DedotClient.new<PolkadotApi>(new WsProvider('wss://rpc.polkadot.io'));

// Now you get full TypeScript support for Polkadot-specific APIs
const balance = await client.query.system.account('ADDRESS');

Examples for Different Networks

import { DedotClient, WsProvider } from 'dedot';
import type { PolkadotApi, KusamaApi, AstarApi, PolkadotAssetHubApi } from '@dedot/chaintypes';

// For Kusama
const kusamaClient = await DedotClient.new<KusamaApi>(new WsProvider('wss://kusama-rpc.polkadot.io'));

// For Astar
const astarClient = await DedotClient.new<AstarApi>(new WsProvider('wss://rpc.astar.network'));

// For Polkadot Asset Hub
const polkadotAssetHubClient = await DedotClient.new<PolkadotAssetHubApi>(
  new WsProvider('wss://polkadot-asset-hub-rpc.polkadot.io')
);

For more detailed information on connecting to networks, see the official documentation.

Supported Networks

  • Polkadot
  • Polkadot Asset Hub
  • Polkadot People
  • Kusama
  • Kusama Asset Hub
  • Kusama People
  • Westend
  • Westend Asset Hub
  • Westend People
  • Paseo
  • Paseo Asset Hub
  • Paseo People
  • Paseo Hydration
  • Astar
  • Moonbeam
  • Aleph
  • Hydration
  • Basilisk
  • Vara

Don't see your network? We welcome Pull Requests to add support for additional PolkadotSDK-based networks!

License

Apache-2.0

版本与发布记录

@dedot/chaintypes 共发布 458 个版本,首次发布于 2024/02/27;过去 12 个月发布了 95 个版本。

版本发布日期距今
0.280.0latest2026/05/096 个月前
0.279.02026/05/086 个月前
0.278.02026/05/086 个月前
0.277.02026/05/076 个月前
0.276.02026/05/056 个月前
0.275.02026/05/046 个月前

其他发布通道:next → 0.73.1-next.1a1272fe.4。

关于 @dedot/chaintypes 的常见问题

@dedot/chaintypes 是什么?

Types for substrate-based chains

如何安装 @dedot/chaintypes?

在项目目录运行 npm install @dedot/chaintypes,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:dedot(>=1.0.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dedot/chaintypes 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dedot/chaintypes 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dedot/chaintypes 可以商用吗?

@dedot/chaintypes 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dedot/chaintypes 的下载量有多少?

根据 npm 官方下载统计,@dedot/chaintypes 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,224 次,日均约 107 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dedot/chaintypes 还在维护吗?

最新版本 0.280.0 发布于 2026/05/09(6 个月前);至今共发布 458 个版本,其中过去 12 个月发布了 95 个;首次发布于 2024/02/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。