/product-sdk:product-sdk-chain-connectionfrom product-sdk
Connects to Polkadot parachains via @parity/product-sdk-chain-client with typed APIs. Supports preset zero-config and BYOD paths for querying chain state and subscribing to storage.
Ships in product-sdk. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
@parity/product-sdk-chain-client provides typed access to Polkadot parachains via polkadot-api (PAPI). It offers two paths: preset (zero-config for known environments) and BYOD (bring your own descriptors for custom setups).
import { getChainAPI } from "@parity/product-sdk-chain-client";
// Inside a container, omit the environment: the host reports which chains it
// serves and the matching descriptors are loaded for you.
const client = await getChainAPI();
// Pin it explicitly when you need a specific environment, or when the host
// predates chain discovery (where the zero-arg form throws).
const paseo = await getChainAPI("paseo");
// Query balance
const account = await client.assetHub.query.System.Account.getValue(
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
);
console.log("Free balance:", account.data.free);
// Clean up
client.destroy();
import { createChainClient } from "@parity/product-sdk-chain-client";
import { paseo_asset_hub } from "@parity/product-sdk-descriptors/paseo-asset-hub";
const client = await createChainClient({
chains: { assetHub: paseo_asset_hub },
});
const account = await client.assetHub.query.System.Account.getValue(
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
);
client.destroy();
getChainAPI (Preset) | createChainClient (BYOD) | |
|---|---|---|
| When | Known environments (paseo, devnet; polkadot and kusama reserved), or whatever the host reports when called with no argument | Custom chains or a subset of chains, as long as the host routes them |
| Descriptors | Built-in, lazy-loaded | You import and provide them |
| Chains | Always assetHub + bulletin + individuality | Any combination you choose |
| Bundle size | Slightly larger (~6.3 MB for all 3 chains) | Minimal (only what you import) |
Use getChainAPI when you want zero-config connection to a standard environment.
Use createChainClient when you need:
Descriptors decide what is typed, the host decides what is reachable. There is no
WebSocket fallback, so check with isChainSupported(genesisHash) from @parity/product-sdk-host.
// Get current block number
const blockNumber = await client.assetHub.query.System.Number.getValue();
// Get account info
const account = await client.assetHub.query.System.Account.getValue(address);
// Get specific asset balance
const balance = await client.assetHub.query.Assets.Account.getValue(
assetId,
address
);
// Subscribe to balance changes
const unsubscribe = client.assetHub.query.System.Account.watchValue(
address,
(account) => {
console.log("Balance changed:", account.data.free);
}
);
// Later: stop subscription
unsubscribe();
// Get all entries in a storage map
const entries = await client.assetHub.query.System.Account.getEntries();
for (const [key, value] of entries) {
console.log(key, value.data.free);
}
For advanced use cases (like creating ContractRuntime for contracts), access the raw PAPI client:
import { createContractRuntime } from "@parity/product-sdk-contracts";
const runtime = createContractRuntime(client.raw.assetHub, { atBest: true });
client.raw.<name> is the product's single PolkadotClient for that chain, shared by every
createChainClient config and SDK package that uses the chain. Never call .destroy() on it
directly: that closes the chain for all of them. Release your hold with client.destroy().
The host allows a product only a few chainHead_v1_follow subscriptions per chain, and each
polkadot-api client holds one. createChainClient therefore keeps one client per chain for the
whole product: configs that include the same chain share it, and the chain closes only when the
last ChainClient holding it is destroyed. Don't build your own client from getHostProvider
for a chain you already reach through createChainClient or getClient; outside production
builds the host provider logs an error when a second client in the product follows a chain
another client already follows.
WARNING: Only the
"paseo"and"devnet"environments are currently available. Using"polkadot"or"kusama"will throw an error.
| Environment | Asset Hub | Bulletin | Individuality |
|---|---|---|---|
| paseo (Paseo Next v2) | Yes | Yes | Yes |
| devnet (public Paseo testnet) | Yes | Yes | Yes |
| polkadot (mainnet) | Planned | Planned | Planned |
| kusama (canary) | Planned | Planned | Planned |
Call getChainAPI() with no argument to derive the environment from the host instead of
hard-coding it. The host reports a genesis hash per chain role (AssetHub, Bulletin,
People) and the environment is the bundle whose asset hub genesis matches, so a host on
its own network id still resolves correctly. An explicit environment is cross-checked the
same way: it throws EnvironmentMismatchError when it is not the network the host runs,
and GenesisMismatchError when a bundled descriptor's genesis disagrees with the host
(a stale descriptor bundle, for example after a testnet reset).
"paseo"is not the public Paseo testnet. It targets the Paseo Next v2 chain instances (*-next-*.polkadot.io). For the community-run products devnet on the long-lived Paseo testnet system chains (Asset Hub 1000, People 1004, Bulletin 1010), use"devnet". Endpoint selection is host-owned: descriptors pin chain identity (genesis hash) and the host container picks the RPC — there is no standalone (non-host) transport path.
Destroy a client when done. That gives back its hold on each chain, and a chain closes once no other client holds it:
// Single client
client.destroy();
// All clients (useful in tests)
import { destroyAll } from "@parity/product-sdk-chain-client";
destroyAll();
Forgetting await — getChainAPI() and createChainClient() return Promises.
Using unavailable environments — Only "paseo" and "devnet" work. "polkadot" and "kusama" throw.
Not cleaning up — Call client.destroy() when done to release the chains it holds; a chain closes once no other client holds it.
Barrel importing descriptors — Use subpath imports: @parity/product-sdk-descriptors/paseo-bulletin, NOT @parity/product-sdk-descriptors.
Missing polkadot-api — It's a peer dependency. Always install it alongside chain-client.
Building an extra client for a chain you already have — createClient(await getHostProvider(genesis)) opens another follow on the chain. Use createChainClient or getClient(descriptor) so the product shares one client per chain.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub paritytech/product-sdk --plugin product-sdk11 skills in this plugin
/migrating-to-product-sdkUse when migrating a product codebase to @parity/product-sdk — detects legacy stacks (polkadot-apps, novasamatech, hand-rolled crypto/IPFS, polkadot-api 1.x) in the target repo, decides which migration areas apply, writes a per-repo migration spec, then hands off to writing-plans.
/product-sdk-app-builderEnd-to-end scaffolding and implementation of Polkadot applications using @parity/product-sdk packages. Use when: creating a new Polkadot project, building a dApp, scaffolding chain interactions, choosing which @parity/product-sdk packages to install, or when a user says "build me a Polkadot app". Handles both developer-guided and fully autonomous (non-developer) workflows.
/Other plugins' skills for the same job