/product-sdk:product-sdk-transactionsfrom product-sdk
Submits transactions, connects wallets, manages signers, and handles key derivation using @parity/product-sdk packages. Covers tx submission/watching, multi-provider wallet accounts, dev signers, and QR/mobile CLI sign-in.
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.
This skill covers three packages that work together for submitting on-chain transactions:
| Package | Import | Purpose |
|---|---|---|
| tx | @parity/product-sdk-tx | Submit, watch, retry transactions |
| signer | @parity/product-sdk-signer | Manage signing accounts across providers |
| keys | @parity/product-sdk-keys | Derive keys, accounts, and session keys |
| auth | @parity/product-sdk-auth | QR/mobile CLI sign-in + product-account session signers |
import { createDevSigner, submitAndWatch } from "@parity/product-sdk-tx";
import type { TxStatus, TxResult } from "@parity/product-sdk-tx";
// 1. Get a signer (dev signer for testnet)
const alice = createDevSigner("Alice");
// 2. Build a transaction (from PAPI typed API)
// Note: `dest` is a MultiAddress enum — pass as { type: "Id", value: ss58Address }
const tx = api.tx.Balances.transfer_keep_alive({
dest: { type: "Id", value: recipientAddress },
value: 1_000_000_000_000n,
});
// 3. Submit and watch
// Returns Result<TxResult, TxError> — success/failure is the `.ok` discriminant.
// Tx failures come back as err(TxError); they do NOT throw.
const result = await submitAndWatch(tx, alice);
if (!result.ok) {
console.log("Failed", result.error.message);
} else {
// result.value: TxResult { txHash, ok, block: { hash, number, index }, events, dispatchError? }
console.log("Success", result.value.block.hash);
}
WARNING: Dev signers (
createDevSigner) use well-known private keys. They are for local development and testnets ONLY. Never use in production.
WARNING: Three different signer-related types exist in this codebase. Do not confuse them.
| Type | Package | What It Is |
|---|---|---|
CommonSignerTxCreator | @polkadot-api/signers-common | PAPI 3 transaction creator passed to submitAndWatch(). Builds and signs extrinsics. |
SignerAccount | @parity/product-sdk-signer | Account wrapper with address, publicKey, source, and getSigner() that returns a CommonSignerTxCreator. |
SignerManager | @parity/product-sdk-signer | Orchestrator that discovers accounts from multiple providers and manages selection state. |
How they connect:
SignerManager.connect() -> SignerAccount[] -> account.getSigner() -> CommonSignerTxCreator -> submitAndWatch(tx, signer)
From a PAPI typed API:
const tx = api.tx.Balances.transfer_keep_alive({ dest, value });
From an Ink SDK contract (dry-run first):
import { extractTransaction } from "@parity/product-sdk-tx";
const dryRun = await contract.query("mint", { origin, data: { name, price } });
// extractTransaction is sync and returns Result<SubmittableTransaction, TxDryRunError>.
const extracted = extractTransaction(dryRun);
if (!extracted.ok) throw extracted.error; // TxDryRunError
const tx = extracted.value;
import { submitAndWatch } from "@parity/product-sdk-tx";
// TxStatus = "signing" | "broadcasting" | "in-block" | "finalized" | "error"
const result = await submitAndWatch(tx, signer, {
waitFor: "best-block", // or "finalized" (slower but safer)
timeoutMs: 300_000, // 5 minutes default
mortalityPeriod: 256, // ~43 minutes on Polkadot
onStatus: (status: TxStatus) => updateUI(status),
});
// result: Result<TxResult, TxError>
// On success, result.value is TxResult { txHash, ok, block: { hash, number, index }, events, dispatchError? }
if (result.ok) {
console.log(result.value.txHash, result.value.block.hash);
} else {
console.log(result.error.message); // typed TxError
}
Submit multiple transactions as a single atomic batch — one signing prompt, one fee.
import { batchSubmitAndWatch } from "@parity/product-sdk-tx";
const tx1 = client.assetHub.tx.Balances.transfer_keep_alive({ dest: addr1, value: 1_000n });
const tx2 = client.assetHub.tx.Balances.transfer_keep_alive({ dest: addr2, value: 2_000n });
const tx3 = client.assetHub.tx.System.remark({ remark: Binary.fromText("hello") });
// Returns Result<TxResult, TxError>, same as submitAndWatch.
const result = await batchSubmitAndWatch([tx1, tx2, tx3], client.assetHub, signer, {
onStatus: (status: TxStatus) => updateUI(status),
});
if (!result.ok) {
handleBatchFailure(result.error); // e.g. TxBatchError
return;
}
console.log("Batch finalized", result.value.block.hash);
Three batch modes:
| Mode | Behavior |
|---|---|
"batch_all" (default) | Atomic. Reverts all calls if any single call fails. |
"batch" | Best-effort. Stops at first failure but earlier successful calls are not reverted. |
"force_batch" | Like batch but continues after failures. |
import { withRetry, submitAndWatch } from "@parity/product-sdk-tx";
const result = await withRetry(
() => submitAndWatch(tx, signer),
{ maxAttempts: 3, baseDelayMs: 1_000, maxDelayMs: 15_000 },
);
All tx errors extend TxError. submitAndWatch / batchSubmitAndWatch do NOT
throw on tx failure — they return err(TxError). Branch on result.ok and
narrow the typed result.error:
import {
TxError, TxTimeoutError, TxDispatchError,
TxSigningRejectedError, TxDryRunError, TxBatchError,
} from "@parity/product-sdk-tx";
const result = await submitAndWatch(tx, signer);
if (!result.ok) {
const e = result.error;
if (e instanceof TxSigningRejectedError) {
// User rejected signing in wallet
} else if (e instanceof TxDispatchError) {
console.log(e.formatted); // e.g., "Balances.InsufficientBalance"
} else if (e instanceof TxTimeoutError) {
console.log(`Timed out after ${e.timeoutMs}ms`);
} else if (e instanceof TxError) {
// Catch-all for any tx error
}
} else {
// result.value is the TxResult
}
import { createDevSigner, getDevPublicKey } from "@parity/product-sdk-tx";
// Available names: "Alice" | "Bob" | "Charlie" | "Dave" | "Eve" | "Ferdie"
const alice = createDevSigner("Alice");
const result = await submitAndWatch(tx, alice);
import { SignerManager } from "@parity/product-sdk-signer";
const manager = new SignerManager({
ss58Prefix: 42,
dappName: "my-app",
});
// Subscribe to state changes
const unsub = manager.subscribe((state) => {
console.log(state.status, state.accounts, state.selectedAccount);
});
// Connect to the Host API (default). For testing, pass "dev": manager.connect("dev")
const result = await manager.connect();
if (result.ok) {
// Request a product account — its signer routes through
// `host_create_transaction` (PR #96), which preserves arbitrary signed
// extensions (e.g. `AsPgas` on Paseo Next v2), on a pipeline version that
// declares them (version 1 for `AsPgas` on Asset Hub runtime 3004000).
// Required on any chain that ships signed extensions PJS doesn't know about.
// The legacy path (`manager.selectAccount(...)` + `manager.getSigner()`) routes through PJS
// and throws `PJS does not support this signed-extension: AsPgas` on such
// chains — use it only when targeting chains with no unknown extensions.
const productRes = await manager.getProductAccount("my-app.dot", 0);
if (productRes.ok) {
const productAccount = productRes.value;
const txResult = await submitAndWatch(tx, productAccount.getSigner());
}
}
manager.destroy();
See examples/tx-demo/src/main.ts for the
full end-to-end pattern (imports, state, init flow).
@parity/product-sdk-auth)For command-line products, @parity/product-sdk-auth is the shared sign-in
layer: QR/mobile pairing, persisted sessions, a sign-out flow, and a
product-account signer — all bound to a product via injected config (no per-CLI
config.ts). It sits on top of @parity/product-sdk-terminal and derives the
product account the RFC-0022 way the mobile wallet does, via terminal's
deriveProductPublicKey.
The signer it returns signs as the product account (
//product//{productId}/{index}), NOT the wallet's selected account and NOT its root account — so its address matches the funded / allowance-granted account. This is the CLI analogue ofSignerManager.getProductAccount(). It is async; seereferences/keys-api.md.
resolveSigner is the one call to reach for: it returns a dev signer when a
--suri is supplied, otherwise the persisted QR session's product-account
signer.
import { createAuthClient, resolveSigner } from "@parity/product-sdk-auth";
import { submitAndWatch } from "@parity/product-sdk-tx";
// 1. Bind an auth client to your product's config (inject per-product values).
const authClient = createAuthClient({
dappId: "playground", // the CLI's id; the session lives in ~/.polkadot-apps/playground/{core,product}
productId: "playground.dot", // dotNS id the CLI acts as; derives the product account
derivationIndex: 0, // 0 = default product account
network: "paseo-next-v2", // optional; the default. Or a TerminalNetworks entry / custom network
});
// 2. Get a transaction creator: the dev SURI if provided, else the persisted QR session.
// `suri` accepts a dev name (//Alice) OR a full BIP-39 mnemonic with an
// optional //<path> derivation suffix. Throws SignerNotAvailableError if
// neither a suri nor a session is available (prompt the user to `login`).
const resolved = await resolveSigner(authClient, { suri: process.env.SURI }); // suri optional
try {
const result = await submitAndWatch(tx, resolved.signer);
// resolved.address / resolved.addresses (root/product/H160) / resolved.source ("dev" | "session")
// resolved.session is present only for QR/mobile sessions (undefined for dev signers).
} finally {
resolved.destroy(); // REQUIRED: stops the session's core thread
}
connect() + waitForLogin() only authenticate and persist the session —
they do not return a signer. After a successful login, call resolveSigner()
(or authClient.getSessionSigner()) to actually sign.
const conn = await authClient.connect();
if (conn.kind === "existing") {
console.log("Already signed in as", conn.address);
} else {
// Render the QR (terminal UI helpers live under the `/ui` subpath so headless
// consumers don't pull terminal-rendering deps).
console.log(conn.qrCode);
const address = await authClient.waitForLogin(conn.login, (s) => console.log(s.step));
}
// Session is now persisted — resolveSigner()/getSessionSigner() will find it.
// Status formatters + QR renderer (separate entrypoint):
import { renderLoginStatus, renderLogoutStatus, renderQrCode } from "@parity/product-sdk-auth/ui";
Mirror image of the login flow: find the paired session, disconnect it (notifies
the mobile app), and clear the session's core/ and product/ folders in
~/.polkadot-apps/<dappId>/.
const handle = await authClient.findSession();
if (!handle) {
console.log("Not signed in.");
} else {
await authClient.waitForLogout(handle, (s) => console.log(renderLogoutStatus(s)));
// LogoutStatus.step: "disconnecting" | "success" | "partial" (local cleared, remote unreachable) | "error"
}
A fresh session needs allowances before it can sign (statement store / Bulletin /
smart-contract sponsoring). The mobile wallet prompts the user to approve. By
default requestAllocation requests DEFAULT_RESOURCES — BulletinAllowance,
StatementStoreAllowance, and SmartContractAllowance for the default (index 0)
product account. Each outcome is "Allocated", "Rejected" or "NotAvailable".
import { DEFAULT_RESOURCES, summarizeOutcomes } from "@parity/product-sdk-auth";
// requestAllocation takes the SessionHandle from getSessionSigner() (null when not signed in).
const handle = await authClient.getSessionSigner();
if (handle) {
try {
const outcomes = await authClient.requestAllocation(handle); // DEFAULT_RESOURCES
const { granted, rejected, unavailable } = summarizeOutcomes(outcomes, DEFAULT_RESOURCES);
} finally {
handle.destroy();
}
}
When to use which:
SignerManager.getProductAccount()is for in-host / web products (Host API).@parity/product-sdk-authis for standalone CLIs that pair with a phone over QR. Both end at aCommonSignerTxCreatoryou pass tosubmitAndWatch.
import { KeyManager } from "@parity/product-sdk-keys";
// Create from a signature
const km = KeyManager.fromSignature(signatureBytes, signerAddress);
// Derive keys for different purposes
const encKey = km.deriveSymmetricKey("doc:123");
const account = km.deriveAccount("app-account", 42);
const kp = km.deriveKeypairs();
// Export for persistence
const raw = km.exportKey();
import { SessionKeyManager } from "@parity/product-sdk-keys";
import { createLocalKvStore } from "@parity/product-sdk-local-storage";
const store = await createLocalKvStore({ prefix: "session-key" });
const skm = new SessionKeyManager({ store, name: "default" });
const info = await skm.getOrCreate();
// info.mnemonic - BIP39 mnemonic
// info.account - DerivedAccount with signer
import { deriveProductAccountPublicKey } from "@parity/product-sdk-keys";
import { deriveProductPublicKey } from "@parity/product-sdk-terminal";
// Pure step: the product's subtree key (shared by the wallet) + index -> product account key.
const derivedPubKey = deriveProductAccountPublicKey(productSubtreePublicKey, { tag: "Index", value: 0 });
// In a CLI: fetch the subtree key through the paired adapter and derive in one call.
// `handle` is a SessionHandle from authClient.getSessionSigner().
const publicKey = await deriveProductPublicKey(handle.adapter, { productId: "playground.dot", derivationIndex: 0 });
The subtree key comes from the wallet because //product//{productId} is hard; a root account key will not work. deriveProductPublicKey is also exported by @parity/product-sdk-auth. See references/keys-api.md.
Using dev signers in production - createDevSigner uses the well-known dev mnemonic. Use SignerManager for real users.
Confusing signer types - submitAndWatch needs a CommonSignerTxCreator, not a SignerAccount. Call account.getSigner().
Missing await on submitAndWatch - It returns a Promise.
Not handling TxDispatchError - A transaction can be included on-chain but still fail. This comes back as err(TxDispatchError), not a thrown error — always branch on result.ok and inspect result.error.
Forgetting account mapping - EVM contract interactions on Asset Hub require calling ensureAccountMapped first.
Not calling resolved.destroy() (auth) - session signers run the truapi core in a worker thread that keeps the Node process alive; the CLI won't exit cleanly until it's torn down. Call it in a finally.
Signing on a fresh session without allocations (auth) - per the package's own note, RFC-0010 allowances are needed before a fresh session can sign (statement store / Bulletin / smart-contract). Run authClient.requestAllocation(handle) (the SessionHandle from getSessionSigner()) once after first login and let the user approve it on the phone.
Submitting a person-origin call with a plain signer (individuality) - a call that must dispatch as a person rather than an account needs the AsPerson transaction extension, which no plain signer sets. Wrap the signer with withAsPerson from @parity/product-sdk-individuality and pass it to submitAndWatch as usual; see the product-sdk-individuality skill. Doing it by hand fails Invalid.Call before dispatch for a reason that is not in the error.
Feeding a runtime ownership proof through signBytes (host) - every raw-signing path a CommonSignerTxCreator exposes <Bytes>-wraps the payload, so a runtime that verifies the bare bytes (the lite_identity_proof of Resources.register_person on the People chain) rejects the signature with no useful error. getAccountsProvider() exposes signRawUnwatermarkedDeprecated(account, data) and signRawUnwatermarkedDeprecatedWithLegacyAccount({ publicKey }, data), which sign data untouched and return the raw signature bytes. Both are deprecated on the host side too (trinity-user-agents#612), need a host on @parity/truapi 0.16.0+, and prompt the user harder because an unwatermarked signature can authorize a transaction. Reach for them only when a runtime check leaves no alternative, and stay on signBytes everywhere else.
@parity/product-sdk-tx API reference@parity/product-sdk-signer API reference@parity/product-sdk-keys API reference@parity/product-sdk-auth API reference (CLI sign-in, session signers, logout, RFC-0010 allocations)What SKILL.md sets; muted values are Claude Code's defaults
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.
/product-sdk-chain-connectionUse when connecting to Polkadot chains, querying chain state, subscribing to storage, working with typed APIs, or choosing between preset and BYOD paths. Covers @parity/product-sdk-chain-client and @parity/product-sdk-descriptors.
/product-sdk-cloud-storageUse when uploading or retrieving data via Cloud Storage, working with CID-based decentralized storage, or the CloudStorageClient SDK. Covers the store() upload builder, chunked uploads, container-only reads (fetch/query), CID helpers, and authorization.
/product-sdk-contractsUse when interacting with smart contracts (PolkaVM/Solidity) on Asset Hub, using ContractManager with cdm.json manifests, createContract for ad-hoc contracts, ContractRuntime creation, or contract type codegen. Covers @parity/product-sdk-contracts.
/product-sdk-individualityUse when reading a person's personhood or membership standing on the individuality chain from a DotNS username or an account address, when reading the usernames an account holds, or when sending a transaction that must run under a person, lite-person or score-participant origin instead of an account origin. Covers readPersonhoodState, lookupUsername, the seven-state PersonhoodState union, the pure derivation without a chain client and the decode helpers for raw Score.Participants and Resources.Consumers values; the game surface, its prize draws, claiming and sign-up with its airdrop VRFs; productContext, personhoodContext, peopleRing, litePeopleRing and readScoreContext for the ring-VRF proof contexts; withAsPerson, withLiteAlias and the RestrictOrigins requirement that otherwise fails every call; the two-transaction lite personhood bind then sign-up flow with buildLiteAliasBindTx, readLiteSignUpRequirement and signUpWithLiteInviteTx; game registration in one call with registerForGame, readGameSeat, deriveSeat, bindGameSeat and the /host entry's hostGameRegistrationCapabilities; and full-personhood registration with registerMessage, Score.register and withScoreParticipant.
Other plugins' skills for the same job