dedot v0.8.0
Dedot
Delightful JavaScript/TypeScript client for Polkadot & Substrate
Dedot is the next-generation JavaScript client for Polkadot and Substrate-based blockchains. Designed to elevate the dapp development experience, Dedot is built & optimized to be lightweight and tree-shakable, offering precise Types & APIs suggestions for individual Substrate-based blockchains and ink! Smart Contracts. Dedot also helps dapps efficiently connect to multiple chains simultaneously as we head toward a seamless multi-chain future.
Features
- ✅ Small bundle size, tree-shakable (no more bn.js or wasm-blob tight dependencies)
- ✅ Types & APIs suggestions for each individual Substrate-based blockchain network (@dedot/chaintypes)
- ✅ Familiar api style with
@polkadot/api
, easy & fast migration! - ✅ Native TypeScript type system for scale-codec
- ✅ Compatible with
@polkadot/extension
-based wallets - ✅ Support Metadata V14, V15 (latest)
- ✅ Built-in metadata optimization (caching, compact mode ⏳)
- ✅ Build on top of both the new & legacy ( deprecated soon) JSON-RPC APIs
- ✅ Support light clients (e.g: smoldot)
- ✅ Typed Contract APIs
- ✅ Fully-typed low-level JSON-RPC client
!TIP Are you developing an ink! dApp?
Check out Typink (https://typink.dev), a comprehensive toolkit for ink! dApp development, built on Dedot!
Documentation
Check out Dedot documentation on the website: https://dedot.dev
Example
- Install packages
npm i dedot # or yarn, pnpm
npm i -D @dedot/chaintypes
- Connect to the network
import { DedotClient, WsProvider } from 'dedot';
import type { PolkadotApi } from '@dedot/chaintypes';
const provider = new WsProvider('wss://rpc.polkadot.io');
const client = await DedotClient.new<PolkadotApi>(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(<address>);
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(<address>)
console.log('Pending rewards:', pendingRewards);
// await unsub();
// await client.disconnect();
Resources & announcements
Acknowledgment
Dedot take a lot of inspirations from project @polkadot/api. A big thank to all the maintainers/contributors of this awesome library.
Proudly supported by Web3 Foundation Grants Program.
License
3 months ago
4 months ago
4 months ago
4 months ago
6 months ago
7 months ago
8 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
11 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago