Validate an Ink SDK dry-run result and extract the submittable transaction.
Replaces the 5-10 line boilerplate that every contract interaction repeats: check success, parse the error, verify send() exists, and call it.
success
send()
Works with any object whose shape matches the Ink SDK contract query result (typed structurally — no Ink SDK import required):
contract.query("method", { origin, data })
contract.write("method", args, origin)
{ success: boolean; value?: { send?(): ... } }
The dry-run result from a contract query or write simulation.
The submittable transaction, ready to pass to submitAndWatch.
If the dry run failed or the result has no send().
import { extractTransaction, submitAndWatch, createDevSigner } from "@polkadot-apps/tx";const dryRun = await contract.query("createItem", { origin, data: { name, price } });const tx = extractTransaction(dryRun);const result = await submitAndWatch(tx, createDevSigner("Alice")); Copy
import { extractTransaction, submitAndWatch, createDevSigner } from "@polkadot-apps/tx";const dryRun = await contract.query("createItem", { origin, data: { name, price } });const tx = extractTransaction(dryRun);const result = await submitAndWatch(tx, createDevSigner("Alice"));
const tx = extractTransaction(await contract.query("transfer", { origin, data }));const result = await withRetry(() => submitAndWatch(tx, signer)); Copy
const tx = extractTransaction(await contract.query("transfer", { origin, data }));const result = await withRetry(() => submitAndWatch(tx, signer));
Validate an Ink SDK dry-run result and extract the submittable transaction.
Replaces the 5-10 line boilerplate that every contract interaction repeats: check
success, parse the error, verifysend()exists, and call it.Works with any object whose shape matches the Ink SDK contract query result (typed structurally — no Ink SDK import required):
contract.query("method", { origin, data })(Ink SDK)contract.write("method", args, origin)(patched SDK wrappers){ success: boolean; value?: { send?(): ... } }