You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: llms.txt
+341-4Lines changed: 341 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -27837,7 +27837,7 @@ You will learn how to:
27837
27837
- Use a workaround for older runtimes that emit derived message identifiers
27838
27838
- Interpret and handle failed or incomplete messages
27839
27839
27840
-
To demonstrate these techniques, the guide introduces a complete example scenario involving a multi-chain XCM transfer. This scenario will serve as the foundation for explaining the message lifecycle, event tracking, and failure debugging in context.
27840
+
To demonstrate these techniques, the guide introduces a complete example scenario involving a multichain XCM transfer. This scenario will serve as the foundation for explaining the message lifecycle, event tracking, and failure debugging in context.
27841
27841
27842
27842
## Prerequisites
27843
27843
@@ -27954,7 +27954,7 @@ This example uses the `PolkadotXcm.limited_reserve_transfer_assets` extrinsic to
27954
27954
27955
27955
The runtime automatically appends a `SetTopic` instruction to the forwarded XCM. This topic becomes the `message_id` used in both `Sent` and `Processed` events, enabling traceability without manual intervention.
27956
27956
27957
-
Create a new script, `limited-reserve-transfer-assets.ts`
27957
+
Create a new script named `limited-reserve-transfer-assets.ts`
27958
27958
27959
27959
```ts
27960
27960
import {Binary, createClient, Enum} from "polkadot-api";
@@ -28199,14 +28199,14 @@ After submitting the transfer, use the `message_id` to correlate origin and dest
28199
28199
28200
28200
### Define a Scenario: XCM Transfer with Manual `SetTopic`
28201
28201
28202
-
In multi-chain XCM flows, such as transferring assets between two chains, you may want to include a `SetTopic` instruction to **reliably trace the message across all involved chains**.
28202
+
In multichain XCM flows, such as transferring assets between two chains, you may want to include a `SetTopic` instruction to **reliably trace the message across all involved chains**.
28203
28203
28204
28204
- **Origin chain**: Polkadot Asset Hub
28205
28205
- **Destination chain**: Hydration
28206
28206
- **Topic**: Manually assigned via `SetTopic` instruction
28207
28207
- **Goal**: Transfer DOT and trace the XCM using the assigned `message_id`
28208
28208
28209
-
Create a new script, `deposit-reserve-asset-with-set-topic.ts`
28209
+
Create a new script named `deposit-reserve-asset-with-set-topic.ts`
28210
28210
28211
28211
```ts
28212
28212
import {Binary, BlockInfo, createClient, Enum, PolkadotClient, TypedApi} from "polkadot-api";
<span data-ty>✅ Processed Message ID on Hydration matched.</span>
28470
28470
</div>
28471
28471
28472
+
### Define a Scenario: Multi-hop XCM Transfer with Manual `SetTopic`
28472
28473
28474
+
In multichain XCM flows—such as sending assets from one chain to another and then back, you can include a `SetTopic` instruction to **consistently trace the message across all hops**.
28475
+
28476
+
- **Origin chain**: Polkadot Asset Hub
28477
+
- **Destination chain**: Hydration
28478
+
- **Topic**: Manually assigned via `SetTopic` instructions
28479
+
- **Goal**: Transfer DOT and track the XCM using the assigned `message_id` across both chains
28480
+
28481
+
Create a new script named `initiate-reserve-withdraw-with-set-topic.ts`:
28482
+
28483
+
```ts
28484
+
import {Binary, BlockInfo, createClient, Enum, PolkadotClient, TypedApi} from "polkadot-api";
28485
+
import {withPolkadotSdkCompat} from "polkadot-api/polkadot-sdk-compat";
28486
+
import {getPolkadotSigner} from "polkadot-api/signer";
28487
+
import {getWsProvider} from "polkadot-api/ws-provider/web";
28488
+
import {
28489
+
assetHub,
28490
+
hydration,
28491
+
XcmV2MultiassetWildFungibility,
28492
+
XcmV3MultiassetFungibility,
28493
+
XcmV3WeightLimit,
28494
+
XcmV5AssetFilter,
28495
+
XcmV5Instruction,
28496
+
XcmV5Junction,
28497
+
XcmV5Junctions,
28498
+
XcmV5WildAsset,
28499
+
XcmVersionedXcm,
28500
+
} from "@polkadot-api/descriptors";
28501
+
import {sr25519CreateDerive} from "@polkadot-labs/hdkd";
28502
+
import {
28503
+
DEV_PHRASE,
28504
+
entropyToMiniSecret,
28505
+
mnemonicToEntropy,
28506
+
ss58Address,
28507
+
} from "@polkadot-labs/hdkd-helpers";
28508
+
28509
+
const XCM_VERSION = 5;
28510
+
28511
+
const toHuman = (_key: any, value: any) => {
28512
+
if (typeof value === "bigint") {
28513
+
return Number(value);
28514
+
}
28515
+
28516
+
if (value && typeof value === "object" && typeof value.asHex === "function") {
0 commit comments