Skip to content

Commit 95543a1

Browse files
Improve xcm precompile doc
1 parent 83c9681 commit 95543a1

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

develop/smart-contracts/precompiles/xcm-precompile.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ categories: Smart Contracts
88

99
## Introduction
1010

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.
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 using a Solidity interface.
1212

13-
Located at the fixed address `0x00000000000000000000000000000000000a0000`, the XCM precompile offers three primary functions:
13+
Located at the fixed address `0x00000000000000000000000000000000000a0000`, the XCM precompile offers three primary functions:
1414

1515
- **`execute`**: for local XCM execution
1616
- **`send`**: for cross-chain message transmission
1717
- **`weighMessage`**: for cost estimation
1818

1919
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}.
2020

21+
!!!note
22+
The XCM precompile is very barebones. It's the most flexible but as such, doesn't provide abstractions to hide away XCM details. These have to be built on top.
23+
2124
## Precompile Interface
2225

2326
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:
@@ -80,24 +83,25 @@ The function returns a `Weight` struct containing `refTime` and `proofSize` valu
8083
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-05.webp)
8184

8285
!!!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.
86+
You can find many more examples of XCMs in this [gist](https://gist.github.com/franciscoaguirre/a6dea0c55e81faba65bedf700033a1a2){target=\_blank} which connects to the Polkadot Hub testnet.
8487

8588
### Execute a Message
8689

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.
90+
The `execute` function runs an XCM message locally using the caller's origin.
91+
This function is the main entrypoint to cross-chain interactions.
8892

8993
Follow these steps to execute a message:
9094

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:
95+
1. Call `weighMessage` with your message to get the required weight.
96+
2. Pass the same message bytes and the weight obtained from the previous step to `execute`.
97+
For example, using the same message from the weighing example, you would call `execute` with:
9498

9599
- `message`: The encoded XCM message bytes.
96-
- `weight`: The `Weight` struct returned from `callWeighMessage`.
100+
- `weight`: The `Weight` struct returned from `weighMessage`.
97101

98102
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.
99103

100-
5. Click on the **Transact** button to execute the xcm message:
104+
3. On Remix, click on the **Transact** button to execute the xcm message:
101105

102106
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-06.webp)
103107

@@ -109,13 +113,13 @@ Additionally, you can verify that the execution of this specific message was suc
109113

110114
### Send a Message
111115

112-
The `send` function is responsible for transmitting an XCM message to a destination chain, enabling essential cross-chain communication.
116+
While most cross-chain operations can be done via `execute`, sometimes `send` is needed, for example, when opening HRMP channels.
113117

114118
To send a message:
115119

116120
1. Prepare your destination location encoded in XCM format.
117121
2. Prepare your XCM message (similar to the execute example).
118-
3. Call `callXcmSend` with both parameters.
122+
3. Call `send` with both parameters.
119123

120124
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.
121125

llms.txt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12479,16 +12479,19 @@ categories: Smart Contracts
1247912479

1248012480
## Introduction
1248112481

12482-
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.
12482+
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 using a Solidity interface.
1248312483

12484-
Located at the fixed address `0x00000000000000000000000000000000000a0000`, the XCM precompile offers three primary functions:
12484+
Located at the fixed address `0x00000000000000000000000000000000000a0000`, the XCM precompile offers three primary functions:
1248512485

1248612486
- **`execute`**: for local XCM execution
1248712487
- **`send`**: for cross-chain message transmission
1248812488
- **`weighMessage`**: for cost estimation
1248912489

1249012490
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}.
1249112491

12492+
!!!note
12493+
The XCM precompile is very barebones. It's the most flexible but as such, doesn't provide abstractions to hide away XCM details. These have to be built on top.
12494+
1249212495
## Precompile Interface
1249312496

1249412497
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:
@@ -12591,24 +12594,25 @@ The function returns a `Weight` struct containing `refTime` and `proofSize` valu
1259112594
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-05.webp)
1259212595

1259312596
!!!note
12594-
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.
12597+
You can find many more examples of XCMs in this [gist](https://gist.github.com/franciscoaguirre/a6dea0c55e81faba65bedf700033a1a2){target=\_blank} which connects to the Polkadot Hub testnet.
1259512598

1259612599
### Execute a Message
1259712600

12598-
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.
12601+
The `execute` function runs an XCM message locally using the caller's origin.
12602+
This function is the main entrypoint to cross-chain interactions.
1259912603

1260012604
Follow these steps to execute a message:
1260112605

12602-
1. Call `callWeighMessage` with your XCM message to get the required weight.
12603-
2. Use the returned weight values when calling `callXcmExecute`.
12604-
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:
12606+
1. Call `weighMessage` with your message to get the required weight.
12607+
2. Pass the same message bytes and the weight obtained from the previous step to `execute`.
12608+
For example, using the same message from the weighing example, you would call `execute` with:
1260512609

1260612610
- `message`: The encoded XCM message bytes.
12607-
- `weight`: The `Weight` struct returned from `callWeighMessage`.
12611+
- `weight`: The `Weight` struct returned from `weighMessage`.
1260812612

1260912613
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.
1261012614

12611-
5. Click on the **Transact** button to execute the xcm message:
12615+
3. On Remix, click on the **Transact** button to execute the xcm message:
1261212616

1261312617
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-06.webp)
1261412618

@@ -12620,13 +12624,13 @@ Additionally, you can verify that the execution of this specific message was suc
1262012624

1262112625
### Send a Message
1262212626

12623-
The `send` function is responsible for transmitting an XCM message to a destination chain, enabling essential cross-chain communication.
12627+
While most cross-chain operations can be done via `execute`, sometimes `send` is needed, for example, when opening HRMP channels.
1262412628

1262512629
To send a message:
1262612630

1262712631
1. Prepare your destination location encoded in XCM format.
1262812632
2. Prepare your XCM message (similar to the execute example).
12629-
3. Call `callXcmSend` with both parameters.
12633+
3. Call `send` with both parameters.
1263012634

1263112635
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.
1263212636

0 commit comments

Comments
 (0)