|
1 | 1 | --- |
2 | | -title: Transfer Tokens Between Parachains |
| 2 | +title: Transfer Assets Between Parachains |
3 | 3 | description: A step-by-step guide to using the ParaSpell XCM SDK to build, verify, and execute a transfer from one Parachain to another. |
4 | 4 | url: https://docs.polkadot.com/chain-interactions/send-transactions/interoperability/transfer-assets-parachains/ |
5 | 5 | --- |
6 | 6 |
|
7 | | -# Transfer Tokens Between Parachains |
| 7 | +# Transfer Assets Between Parachains |
8 | 8 |
|
9 | 9 | ## Introduction |
10 | 10 |
|
11 | | -This guide walks you through transferring tokens between two parachains using the [ParaSpell XCM SDK](https://paraspell.github.io/docs/){target=\_blank}. This example utilizes [Asset Hub](/polkadot-protocol/architecture/system-chains/asset-hub/){target=\_blank} and the [People Chain](/polkadot-protocol/architecture/system-chains/people/){target=\_blank}. However, the same approach can be applied to transfers between other parachains. |
| 11 | +This guide walks you through transferring tokens between two parachains using the [ParaSpell XCM SDK](/reference/tools/paraspell/){target=\_blank}. This example utilizes [Asset Hub](/polkadot-protocol/architecture/system-chains/asset-hub/){target=\_blank} and the [People Chain](/polkadot-protocol/architecture/system-chains/people/){target=\_blank}. However, the same approach can be applied to transfers between other parachains. |
12 | 12 |
|
13 | 13 | For development purposes, this guide will use the [Polkadot TestNet](/develop/networks/#paseo){target=\_blank}, so the transferred token will be PAS. |
14 | 14 |
|
15 | 15 | In this guide, you will: |
16 | 16 |
|
17 | 17 | - Build an XCM transfer transaction using ParaSpell XCM SDK. |
18 | 18 | - Perform a dry run to validate the transfer. |
19 | | -- Verify the [Existential Deposit (ED)](/polkadot-protocol/glossary/#existential-deposit){target=\_blank} requirement on the destination chain. |
| 19 | +- Verify the [Existential Deposit (ED)](/reference/glossary/#existential-deposit){target=\_blank} requirement on the destination chain. |
20 | 20 | - Retrieve information regarding the transfer, along with fee estimates. |
21 | 21 | - Submit the transaction. |
22 | 22 |
|
23 | 23 | ### Prerequisites |
24 | 24 |
|
25 | 25 | Before you begin, ensure you have the following: |
26 | 26 |
|
27 | | -- Knowledge of the [fundamentals of Polkadot](/polkadot-protocol/parachain-basics/){target=\_blank}. |
28 | | -- Basic understanding of [XCM](/develop/interoperability/intro-to-xcm/){target=\_blank}. |
| 27 | +- Knowledge of the [fundamentals of Polkadot](/parachains/get-started/){target=\_blank}. |
| 28 | +- Basic understanding of [XCM](/parachains/interoperability/get-started/){target=\_blank}. |
29 | 29 | - Basic familiarity with JavaScript or TypeScript. |
30 | | -- Installed [bun](https://bun.com/docs/installation){target=\_blank}, a JavaScript and TypeScript package manager. |
| 30 | +- Installed [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm){target=\_blank}, a JavaScript and TypeScript package manager. |
31 | 31 |
|
32 | 32 | ## Initialize Your Project |
33 | 33 |
|
34 | 34 | Create the project folder: |
35 | 35 |
|
36 | 36 | ```bash |
37 | | -mkdir paraspell-transfer |
| 37 | +mkdir paraspell-transfer && \ |
38 | 38 | cd paraspell-transfer |
39 | 39 | ``` |
40 | 40 |
|
41 | 41 | Initialize the JavaScript project: |
42 | 42 |
|
43 | 43 | ```bash |
44 | | -bun init -y |
| 44 | +npm init -y |
| 45 | +``` |
| 46 | + |
| 47 | +Install dev dependencies: |
| 48 | + |
| 49 | +```bash |
| 50 | +npm install --save-dev @types/node@^22.12.0 tsx@^4.20.6 typescript@^5.7.3 |
45 | 51 | ``` |
46 | 52 |
|
47 | 53 | Install the required dependencies: |
48 | 54 |
|
49 | 55 | ```bash |
50 | | -bun add @paraspell/sdk@11. 3.2 polkadot-api@1. 17.1 @polkadot-labs/ [email protected]. 25 @polkadot-labs/ [email protected]. 24 |
| 56 | +npm install --save @paraspell/sdk@11. 12.6 polkadot-api@1. 20.0 @polkadot-labs/ [email protected]. 26 @polkadot-labs/ [email protected]. 25 |
51 | 57 | ``` |
52 | 58 |
|
53 | 59 | Now add the following setup code to `index.ts`: |
@@ -154,13 +160,13 @@ dryRunTransfer(); |
154 | 160 | Run the script using the following command: |
155 | 161 |
|
156 | 162 | ```bash |
157 | | -bun run index.ts |
| 163 | +npx tsx index.ts |
158 | 164 | ``` |
159 | 165 |
|
160 | 166 | The result of the dry run will look similar to the following example output: |
161 | 167 |
|
162 | 168 | <div id="termynal" data-termynal> |
163 | | - <span data-ty="input"><span class="file-path"></span>bun run index.ts</span> |
| 169 | + <span data-ty="input"><span class="file-path"></span>npx tsx index.ts</span> |
164 | 170 | <span data-ty>{ |
165 | 171 | failureReason: undefined, |
166 | 172 | failureChain: undefined, |
@@ -313,13 +319,13 @@ verifyED(); |
313 | 319 | Comment out the `dryRunTransfer()` function so that it is not executed again. Then, execute the `verifyED()` by running the following command: |
314 | 320 |
|
315 | 321 | ```bash |
316 | | -bun run index.ts |
| 322 | +npx tsx index.ts |
317 | 323 | ``` |
318 | 324 |
|
319 | 325 | After that, you will get output confirming the ED which will look similar to the following: |
320 | 326 |
|
321 | 327 | <div id="termynal" data-termynal> |
322 | | - <span data-ty="input"><span class="file-path"></span>bun run index.ts</span> |
| 328 | + <span data-ty="input"><span class="file-path"></span>npx tsx index.ts</span> |
323 | 329 | <span data-ty>ED verification successful.</span> |
324 | 330 | </div> |
325 | 331 | ## Get Transfer Info and Fee Estimates |
@@ -351,13 +357,13 @@ XcmTransferInfo(); |
351 | 357 | Comment out the `verifyED()` function so it doesn't execute again. Then, execute the `XcmTransferInfo()` function by running the following command: |
352 | 358 |
|
353 | 359 | ```bash |
354 | | -bun run index.ts |
| 360 | +npx tsx index.ts |
355 | 361 | ``` |
356 | 362 |
|
357 | 363 | You will see all the information for your transfer similar to the following example: |
358 | 364 |
|
359 | 365 | <div id="termynal" data-termynal> |
360 | | - <span data-ty="input"><span class="file-path"></span>bun run index.ts</span> |
| 366 | + <span data-ty="input"><span class="file-path"></span>npx tsx index.ts</span> |
361 | 367 | <span data-ty>Transfer Info: { |
362 | 368 | chain: { |
363 | 369 | origin: "AssetHubPaseo", |
@@ -420,13 +426,13 @@ transfer(); |
420 | 426 | Comment out the `XcmTransferInfo()` function so it doesn't execute again. Then, execute the transfer by running the following command: |
421 | 427 |
|
422 | 428 | ```bash |
423 | | -bun run index.ts |
| 429 | +npx tsx index.ts |
424 | 430 | ``` |
425 | 431 |
|
426 | 432 | Your `transfer` function will submit the transaction, and you will get the following output: |
427 | 433 |
|
428 | 434 | <div id="termynal" data-termynal> |
429 | | - <span data-ty="input"><span class="file-path"></span>bun run index.ts</span> |
| 435 | + <span data-ty="input"><span class="file-path"></span>npx tsx index.ts</span> |
430 | 436 | <span data-ty>...</span> |
431 | 437 | <span data-ty>Built transaction: { |
432 | 438 | getPaymentInfo: [AsyncFunction: getPaymentInfo], |
@@ -873,4 +879,4 @@ You have now successfully created and sent a cross-chain transfer using the Para |
873 | 879 |
|
874 | 880 | - Read the Docs: Dive deeper into the features of the [ParaSpell XCM SDK](https://paraspell.github.io/docs/sdk/getting-started.html){target=\_blank} documentation. |
875 | 881 |
|
876 | | -- Learn about XCM: Understand the underlying protocol by visiting the [Introduction to XCM page](/develop/interoperability/intro-to-xcm/) in the Polkadot Docs. |
| 882 | +- Learn about XCM: Understand the underlying protocol by visiting the [Introduction to XCM page](/parachains/interoperability/get-started/) in the Polkadot Docs. |
0 commit comments