author_submitAndWatchExtrinsic
author_submitAndWatchExtrinsic
broadcasts a signed extrinsic and subscribes to status notifications such as Ready
, InBlock
, and Finalized
. This is the preferred flow when your application must react immediately to zkSBT issuance, credential revocations, or shielded transfers.
âšī¸ This call requires a WebSocket transport. HTTP endpoints will return an error because they cannot keep the subscription alive.
Parametersâ
Parameter | Type | Required | Description |
---|---|---|---|
extrinsic | string | Yes | Hex-encoded, signed SCALE extrinsic. |
Returnsâ
A subscription ID. The node streams status notifications to the client until you call author_unwatchExtrinsic
or the extrinsic reaches Finalized
/Dropped
.
WebSocket Exampleâ
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
const subscription = await api.rpc.author.submitAndWatchExtrinsic(signedExtrinsic, ({ status, events }) => {
if (status.isReady) {
console.log('Extrinsic queued');
}
if (status.isInBlock) {
console.log('Included in block', status.asInBlock.toHex());
}
if (status.isFinalized) {
console.log('Finalized in', status.asFinalized.toHex());
events
.filter(({ event }) => api.events.system.ExtrinsicSuccess.is(event))
.forEach(() => console.log('â
Execution success'));
}
});
// Later, to stop receiving updates
await api.rpc.author.unwatchExtrinsic(subscription);
JSON-RPC Framesâ
// Request
{
"jsonrpc": "2.0",
"method": "author_submitAndWatchExtrinsic",
"params": [
"0x450284008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48"
],
"id": 1
}
// Example notification
{
"jsonrpc": "2.0",
"method": "author_extrinsicUpdate",
"params": {
"result": {
"inBlock": "0x12dbd70ed24bffa8ecf8a0ac1a3ab639cdb4ce462f32fbfa33f33017dae6a604"
},
"subscription": "0x1"
}
}
Operational Tipsâ
- Use this stream when you need deterministic confirmation before issuing off-chain credentials or releasing private liquidity.
- Combine with
author_pendingExtrinsics
to detect if the extrinsic stalled before reachingReady
. - Remember to unwatch long-running subscriptions to avoid WebSocket leaks.