Skip to content

Repository files navigation

@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 Polkadotimporttype{PolkadotApi}from'@dedot/chaintypes';// Import types for Kusamaimporttype{KusamaApi}from'@dedot/chaintypes';// Import types for other networksimporttype{AstarApi,MoonbeamApi,// ... other networks}from'@dedot/chaintypes';

You can also import types for specific networks directly:

// Import types for Polkadot directlyimporttype{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';importtype{PolkadotApi}from'@dedot/chaintypes';// Initialize a typed client for Polkadotconstclient=awaitDedotClient.new<PolkadotApi>(newWsProvider('wss://rpc.polkadot.io'));// Now you get full TypeScript support for Polkadot-specific APIsconstbalance=awaitclient.query.system.account('ADDRESS');

Examples for Different Networks

import{DedotClient,WsProvider}from'dedot';importtype{PolkadotApi,KusamaApi,AstarApi,PolkadotAssetHubApi}from'@dedot/chaintypes';// For KusamaconstkusamaClient=awaitDedotClient.new<KusamaApi>(newWsProvider('wss://kusama-rpc.polkadot.io'));// For AstarconstastarClient=awaitDedotClient.new<AstarApi>(newWsProvider('wss://rpc.astar.network'));// For Polkadot Asset HubconstpolkadotAssetHubClient=awaitDedotClient.new<PolkadotAssetHubApi>(newWsProvider('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

About

Chaintypes for PolkadotSDK-based blockchain networks

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages