Skip to content

Commit 6beae32

Browse files
committed
Merge branch 'master' into bruno/transaction-construction
2 parents 69c6e5b + 83c9681 commit 6beae32

File tree

18 files changed

+732
-10
lines changed

18 files changed

+732
-10
lines changed

.pages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ nav:
44
- infrastructure
55
- polkadot-protocol
66
- tutorials
7+
- get-support
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
title: Precompiles
22
nav:
33
- index.md
4-
- 'Interact With Precompiles': interact-with-precompiles.md
4+
- 'Interact With Precompiles': interact-with-precompiles.md
5+
- 'XCM Precompile': xcm-precompile.md
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: Interact with the XCM Precompile
3+
description: Learn how to use the XCM precompile to send cross-chain messages, execute XCM instructions, and estimate costs from your smart contracts.
4+
categories: Smart Contracts
5+
---
6+
7+
# XCM Precompile
8+
9+
## Introduction
10+
11+
The [XCM (Cross-Consensus Message)](/develop/interoperability/intro-to-xcm){target=\_blank} precompile enables Polkadot Hub developers to access XCM functionality directly from their smart contracts, sending cross-chain messages, executing XCM instructions locally, and estimating execution costs—all through a standardized Solidity interface.
12+
13+
Located at the fixed address `0x00000000000000000000000000000000000a0000`, the XCM precompile offers three primary functions:
14+
15+
- **`execute`**: for local XCM execution
16+
- **`send`**: for cross-chain message transmission
17+
- **`weighMessage`**: for cost estimation
18+
19+
This guide demonstrates how to interact with the XCM precompile through Solidity smart contracts using [Remix IDE](/develop/smart-contracts/dev-environments/remix.md){target=\_blank}.
20+
21+
## Precompile Interface
22+
23+
The XCM precompile implements the `IXcm` interface, which defines the structure for interacting with XCM functionality. The source code for the interface is as follows:
24+
25+
```solidity title="IXcm.sol"
26+
--8<-- "https://raw.githubusercontent.com/paritytech/polkadot-sdk/cb629d46ebf00aa65624013a61f9c69ebf02b0b4/polkadot/xcm/pallet-xcm/src/precompiles/IXcm.sol"
27+
```
28+
29+
The interface defines a `Weight` struct that represents the computational cost of XCM operations. Weight has two components:
30+
31+
- **`refTime`**: computational time on reference hardware
32+
- **`proofSize`**: the size of the proof required for execution
33+
34+
All XCM messages must be encoded using the [SCALE codec](/polkadot-protocol/parachain-basics/data-encoding/#data-encoding){target=\_blank}, Polkadot's standard serialization format.
35+
36+
For further information, check the [`precompiles/IXCM.sol`](https://github.com/paritytech/polkadot-sdk/blob/cb629d46ebf00aa65624013a61f9c69ebf02b0b4/polkadot/xcm/pallet-xcm/src/precompiles/IXcm.sol){target=\_blank} file present in the `pallet-xcm`.
37+
38+
## Interact with the XCM Precompile
39+
40+
To interact with the XCM precompile, you can use the precompile interface directly in [Remix IDE](/develop/smart-contracts/dev-environments/remix.md){target=\_blank}:
41+
42+
1. Create a new file called `IXcm.sol` in Remix.
43+
2. Copy and paste the `IXcm` interface code into the file.
44+
3. Compile the interface by selecting the button or using **Ctrl +S** keys:
45+
46+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-01.webp)
47+
48+
4. In the **Deploy & Run Transactions** tab, select the `IXcm` interface from the contract dropdown.
49+
5. Enter the precompile address `0x00000000000000000000000000000000000a0000` in the **At Address** input field.
50+
6. Select the **At Address** button to connect to the precompile.
51+
52+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-02.webp)
53+
54+
7. Once connected, you can use the Remix interface to interact with the XCM precompile's `execute`, `send`, and `weighMessage` functions.
55+
56+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-03.webp)
57+
58+
### Weigh a Message
59+
60+
The `weighMessage` function estimates the computational cost required to execute an XCM message. This estimate is crucial for understanding the resources needed before actually executing or sending a message.
61+
62+
To test this functionality in Remix, you can call `callWeighMessage` with a SCALE-encoded XCM message. For example, for testing, you can use the following encoded XCM message:
63+
64+
```text title="encoded-xcm-message-example"
65+
0x050c000401000003008c86471301000003008c8647000d010101000000010100368e8759910dab756d344995f1d3c79374ca8f70066d3a709e48029f6bf0ee7e
66+
```
67+
68+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-04.webp)
69+
70+
This encoded message represents a sequence of XCM instructions:
71+
72+
- **[Withdraw Asset](https://github.com/polkadot-fellows/xcm-format?tab=readme-ov-file#withdrawasset){target=\_blank}**: This instruction removes assets from the local chain's sovereign account or the caller's account, making them available for use in subsequent XCM instructions.
73+
- **[Buy Execution](https://github.com/polkadot-fellows/xcm-format?tab=readme-ov-file#buyexecution){target=\_blank}**: This instruction purchases execution time on the destination chain using the withdrawn assets, ensuring the message can be processed.
74+
- **[Deposit Asset](https://github.com/polkadot-fellows/xcm-format?tab=readme-ov-file#depositasset){target=\_blank}**: This instruction deposits the remaining assets into a specified account on the destination chain after execution costs have been deducted.
75+
76+
This encoded message is provided as an example. You can craft your own XCM message tailored to your specific use case as needed.
77+
78+
The function returns a `Weight` struct containing `refTime` and `proofSize` values, which indicate the estimated computational cost of executing this message. If successful, after calling the `callWeighMessage` function, you should see the `refTime` and `proofSize` of the message:
79+
80+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-05.webp)
81+
82+
!!!note
83+
To interact with Polkadot Hub TestNet, visit this [gist](https://gist.github.com/franciscoaguirre/a6dea0c55e81faba65bedf700033a1a2){target=\_blank}, which provides examples of how to craft XCM messages for different purposes.
84+
85+
### Execute a Message
86+
87+
The `execute` function runs an XCM message locally using the caller's origin. This function helps execute XCM instructions that don't require cross-chain communication.
88+
89+
Follow these steps to execute a message:
90+
91+
1. Call `callWeighMessage` with your XCM message to get the required weight.
92+
2. Use the returned weight values when calling `callXcmExecute`.
93+
3. Pass the same XCM message bytes and the weight obtained from the previous step. For example, using the same message from the weighing example, you would call `callXcmExecute` with:
94+
95+
- `message`: The encoded XCM message bytes.
96+
- `weight`: The `Weight` struct returned from `callWeighMessage`.
97+
98+
You can use the [papi console](https://dev.papi.how/extrinsics#networkId=localhost&endpoint=wss%3A%2F%2Ftestnet-passet-hub.polkadot.io&data=0x1f03050c000401000003008c86471301000003008c8647000d010101000000010100368e8759910dab756d344995f1d3c79374ca8f70066d3a709e48029f6bf0ee7e0750c61e2901daad0600){target=\_blank} to examine the complete extrinsic structure for this operation.
99+
100+
5. Click on the **Transact** button to execute the xcm message:
101+
102+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-06.webp)
103+
104+
If successful, you will see the following output in the Remix terminal:
105+
106+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-07.webp)
107+
108+
Additionally, you can verify that the execution of this specific message was successful by checking that the beneficiary account associated with the XCM message has received the funds accordingly.
109+
110+
### Send a Message
111+
112+
The `send` function is responsible for transmitting an XCM message to a destination chain, enabling essential cross-chain communication.
113+
114+
To send a message:
115+
116+
1. Prepare your destination location encoded in XCM format.
117+
2. Prepare your XCM message (similar to the execute example).
118+
3. Call `callXcmSend` with both parameters.
119+
120+
The destination parameter must be encoded according to XCM's location format, specifying the target parachain or consensus system. The message parameter contains the XCM instructions to be executed on the destination chain.
121+
122+
Unlike `execute`, the `send` function doesn't require a weight parameter since the destination chain will handle execution costs according to its fee structure.
123+
124+
## Cross Contract Calls
125+
126+
Beyond direct interaction and wrapper contracts, you can integrate XCM functionality directly into your existing smart contracts by inheriting from or importing the `IXcm` interface. This approach enables you to embed cross-chain capabilities into your application logic seamlessly.
127+
128+
Whether you're building DeFi protocols, governance systems, or any application requiring cross-chain coordination, you can incorporate XCM calls directly within your contract's functions.
129+
130+
## Conclusion
131+
132+
The XCM precompile provides a powerful interface for cross-chain interactions within the Polkadot ecosystem. By understanding how to properly encode messages, estimate weights, and execute or send XCM instructions, developers can build sophisticated cross-chain applications that leverage the full potential of Polkadot's interoperability features.

get-support/.pages

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
title: Get Support
2+
nav:
3+
- index.md
4+
- 'Get In Touch Directly': get-in-touch.md
5+
- 'Explore More Resources': explore-resources.md

get-support/explore-resources.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Subscribe to Updates
3+
description: Find Polkadot developer resources, tutorials, forums, governance proposals, and community platforms like StackExchange, Reddit, and YouTube.
4+
template: index-page.html
5+
hide:
6+
- footer
7+
---
8+
9+
# Ask the Community and Explore Resources
10+
11+
Looking for answers beyond the documentation?
12+
These platforms are full of useful content and experienced developers sharing insights.
13+
14+
## 🧠 Stack Exchange
15+
16+
- Browse commonly asked technical questions.
17+
- Ask your own and get detailed responses from experienced devs.
18+
19+
👉 **[Visit Polkadot Stack Exchange](https://substrate.stackexchange.com/){target=\_blank}**
20+
21+
## 🧵 Reddit: r/Polkadot
22+
23+
- General Polkadot discussions and community perspectives.
24+
- Developer questions are welcome — just tag them appropriately.
25+
26+
👉 **[Visit r/Polkadot](https://www.reddit.com/r/Polkadot/){target=\_blank}**
27+
28+
## 💬 Discord (Community Threads Only)
29+
30+
- Beyond the official support threads, most channels are community-driven.
31+
- Great place to connect with fellow builders and share insights.
32+
33+
👉 **[Join the Polkadot Discord](https://polkadot-discord.w3f.tools/){target=\_blank}**
34+
35+
## 🎥 YouTube: @PolkadotNetwork
36+
37+
- Developer tutorials
38+
- Ecosystem interviews
39+
- Event recordings and walkthroughs
40+
41+
👉 **[Watch on YouTube](https://www.youtube.com/@PolkadotNetwork){target=\_blank}**
42+
43+
---
44+
45+
# Community-led Platforms and Ecosystem Updates
46+
47+
Stay in sync with what's happening across the Polkadot ecosystem — from official announcements to community-driven insights and governance activity.
48+
49+
## 🔷 X (Twitter): Official Accounts
50+
51+
- [@PolkadotDevs](https://twitter.com/PolkadotDevs){target=\_blank} — updates for developers
52+
- [@Polkadot](https://twitter.com/Polkadot){target=\_blank} — network-wide news
53+
- [@Kusamanetwork](https://twitter.com/kusamanetwork){target=\_blank} — Kusama-specific updates
54+
- [@Web3Foundation](https://twitter.com/web3foundation){target=\_blank} — grants, research, and ecosystem programs
55+
56+
## 🔁 X (Twitter): Community Accounts
57+
58+
- [@PolkadotDeploy](https://twitter.com/PolkadotDeploy){target=\_blank} — news from the deployment portal and tooling updates
59+
60+
## 🗣️ Polkadot Forum
61+
62+
- Join community discussions around the direction of the ecosystem.
63+
64+
👉 **[Visit Polkadot Forum](https://forum.polkadot.network/){target=\_blank}**
65+
66+
## 🧑‍⚖️ Polkassembly: OpenGov
67+
68+
- Explore and vote on governance proposals for Polkadot and Kusama.
69+
- Help shape the future of the network.
70+
71+
👉 **[Explore on Polkassembly](https://polkadot.polkassembly.io/){target=\_blank}**
72+
73+
## 📸 Instagram
74+
75+
- **[@Polkadotnetwork](https://www.instagram.com/polkadotnetwork){target=\_blank}** — visual highlights from the ecosystem
76+
_(Note: not developer-specific)_

get-support/get-in-touch.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Get in Touch
3+
description: Developer support for Polkadot via Telegram, Matrix, and Discord. Get help with parachains, smart contracts, nodes, and ecosystem tools.
4+
template: index-page.html
5+
hide:
6+
- footer
7+
---
8+
9+
# Get in Touch Directly
10+
11+
## Need Help Fast?
12+
13+
Use one of the channels below to get live technical support or ask questions.
14+
15+
<div class="button-wrapper" style="display: flex; justify-content: flex-start;">
16+
<a href="https://t.me/substratedevs" class="md-button" style="margin-right: 1rem; text-decoration: none;">
17+
Connect to Telegram
18+
</a>
19+
<a href="https://polkadot-discord.w3f.tools/" class="md-button" style="text-decoration: none;">
20+
Connect to Discord
21+
</a>
22+
</div>
23+
24+
Prefer to see all available channels? Here are your options:
25+
26+
## 📱 Telegram: Polkadot Developer Support
27+
28+
The fastest way to get support.
29+
30+
- **Who’s there:** DevRel team and active developer community
31+
- **Response time:** within **2 business days (usually faster)**
32+
- **Topics:** any developer-related question is welcome
33+
34+
👉 **[Join Telegram](https://t.me/substratedevs){target=\_blank}**
35+
36+
## 🔌 Discord: Polkadot Official Server
37+
38+
Focused support for smart contracts and general developer chat.
39+
40+
- **Smart contracts:**
41+
Ask in `#solidity-smart-contracts` and `#ink_smart-contracts`
42+
- **General developer support:**
43+
Ask in `#solidity-smart-contracts`
44+
- **Response time:** within **1 business day (usually faster)**
45+
- **Other topics:** community-led discussion only
46+
47+
👉 **[Join Discord](https://polkadot-discord.w3f.tools/){target=\_blank}**
48+
49+
## 🧬 Matrix: Polkadot Developer Support
50+
51+
This is the **support channel** staffed by engineers from **Parity**, **Web3 Foundation**, and **Polkadot DevRel**.
52+
53+
- **Who’s there:** Parity, W3F, DevRel, and community contributors
54+
- **Response time:** within **1 business day (usually faster)**
55+
- **Topics:** full-spectrum developer support
56+
- Bridged with Telegram (all messages synced)
57+
58+
👉 **[Join Matrix](https://matrix.to/#/#substratedevs:matrix.org){target=\_blank}**
59+
60+
---
61+
62+
Not sure where to start?
63+
64+
**Join Telegram above** — let us know what you need, and we’ll help you get unstuck.

get-support/index.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Get Support
3+
description: Start here to get developer support for Polkadot. Connect with the team, find help, and explore resources beyond the documentation.
4+
template: index-page.html
5+
hide:
6+
- footer
7+
---
8+
9+
# Need Help Fast?
10+
Use one of the channels below to get live technical support or ask questions.
11+
12+
<div class="button-wrapper" style="display: flex; justify-content: flex-start;">
13+
<a href="https://t.me/substratedevs" class="md-button" style="margin-right: 1rem; text-decoration: none;">
14+
Connect to Telegram
15+
</a>
16+
<a href="https://polkadot-discord.w3f.tools/" class="md-button" style="text-decoration: none;">
17+
Connect to Discord
18+
</a>
19+
</div>
20+
---
21+
22+
## Need More than just Documentation?
23+
24+
You're already in the docs — solid start.
25+
But sometimes you need more: answers, real examples, someone to talk to.
26+
This Support Hub is here to help you move forward — faster.
27+
28+
Whether you're building something new, integrating into the ecosystem, or running into blockers — **don't stay stuck**.
29+
30+
## What You can do Here
31+
32+
- 📨 [**Get In Touch**](./get-in-touch)
33+
Reach out to the Polkadot support team and community via Telegram, Matrix, or Discord.
34+
Ask technical questions, report blockers, or share feedback — and get a human response.
35+
36+
- 🧠 [**Explore Available Resources**](./explore-resources)
37+
Find answers beyond the documentation: developer forums, Stack Exchange, Reddit, YouTube, governance hubs, and more.
38+
---
39+
40+
This hub is evolving. More support tools and shortcuts are on the way —
41+
including better onboarding, CLI helpers, dev environments, and live feedback channels.
42+
43+
## Help us Improve
44+
45+
If something’s missing, unclear, or broken — **tell us**.
46+
Your feedback makes the whole ecosystem better for everyone.
47+
48+
👉 [**Get In Touch**](./get-in-touch) and help shape the future of developer support.
135 KB
Loading
157 KB
Loading
154 KB
Loading

0 commit comments

Comments
 (0)