Skip to content

Commit 065087d

Browse files
committed
fix: formatting
1 parent 987ec0c commit 065087d

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ Follow these steps to execute a message:
9696

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

99-
If successful, you will see the following output in the Remix terminal:
99+
If successful, you will see the following output in the Remix terminal:
100100

101-
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-07.webp)
101+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-07.webp)
102102

103103
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.
104104

llms.txt

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12468,20 +12468,27 @@ Doc-Content: https://docs.polkadot.com/develop/smart-contracts/precompiles/xcm-p
1246812468
--- BEGIN CONTENT ---
1246912469
---
1247012470
title: Interact with the XCM Precompile
12471-
description: Learn how to use the XCM precompile to send cross-chain messages, execute XCM instructions, and estimate costs from your smart contracts
12471+
description: Learn how to use the XCM precompile to send cross-chain messages, execute XCM instructions, and estimate costs from your smart contracts.
12472+
categories: Smart Contracts
1247212473
---
1247312474

1247412475
# XCM Precompile
1247512476

1247612477
## Introduction
1247712478

12478-
The XCM (Cross-Consensus Message) precompile enables Polkadot Hub developers to access XCM functionality directly from their smart contracts. This precompile enables contracts to send cross-chain messages, execute XCM instructions locally, and estimate execution costs—all through a standardized Solidity interface.
12479+
The XCM (Cross-Consensus Message) 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.
1247912480

12480-
Located at the fixed address `0x00000000000000000000000000000000000a0000`, the XCM precompile offers three primary functions: `execute` for local XCM execution, `send` for cross-chain message transmission, and `weighMessage` for cost estimation. 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}.
12481+
Located at the fixed address `0x00000000000000000000000000000000000a0000`, the XCM precompile offers three primary functions:
12482+
12483+
- **`execute`**: for local XCM execution
12484+
-**`send`**: for cross-chain message transmission
12485+
- **`weighMessage`**: for cost estimation
12486+
12487+
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}.
1248112488

1248212489
## Precompile Interface
1248312490

12484-
The XCM precompile implements the `IXcm` interface, which defines the structure for interacting with XCM functionality:
12491+
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:
1248512492

1248612493
```solidity title="IXcm.sol"
1248712494
// SPDX-License-Identifier: MIT
@@ -12527,23 +12534,23 @@ interface IXcm {
1252712534
}
1252812535
```
1252912536

12530-
The interface defines a `Weight` struct that represents the computational cost of XCM operations. Weight has two components: `refTime` (computational time on reference hardware) and `proofSize` (size of the proof needed for execution). 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.
12537+
The interface defines a `Weight` struct that represents the computational cost of XCM operations. Weight has two components: `refTime` (computational time on reference hardware) and `proofSize` (the size of the proof required for execution). 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.
1253112538

1253212539
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`.
1253312540

1253412541
## Interact with the XCM Precompile
1253512542

1253612543
To interact with the XCM precompile, you can use the precompile interface directly in Remix IDE:
1253712544

12538-
1. Create a new file called `IXcm.sol` in Remix
12539-
2. Copy and paste the `IXcm` interface code into the file
12540-
3. Compile the interface
12545+
1. Create a new file called `IXcm.sol` in Remix.
12546+
2. Copy and paste the `IXcm` interface code into the file.
12547+
3. Compile the interface by selecting the button or using **Ctrl +S** keys:
1254112548

1254212549
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-01.webp)
1254312550

12544-
4. In the Deploy & Run Transactions tab, select the `IXcm` interface from the contract dropdown
12545-
5. Enter the precompile address `0x00000000000000000000000000000000000a0000` in the **At Address** input field
12546-
6. Click "At Address" to connect to the precompile
12551+
4. In the Deploy & Run Transactions tab, select the `IXcm` interface from the contract dropdown.
12552+
5. Enter the precompile address `0x00000000000000000000000000000000000a0000` in the **At Address** input field.
12553+
6. Click "At Address" to connect to the precompile.
1254712554

1254812555
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-02.webp)
1254912556

@@ -12553,7 +12560,7 @@ Once connected, you can directly interact with the XCM precompile's functions (`
1255312560

1255412561
### Weight a Message
1255512562

12556-
The `weighMessage` function estimates the computational cost required to execute an XCM message. This is crucial for understanding the resources needed before actually executing or sending a message.
12563+
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.
1255712564

1255812565
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:
1255912566

@@ -12580,46 +12587,46 @@ The function returns a `Weight` struct containing `refTime` and `proofSize` valu
1258012587

1258112588
### Execute a Message
1258212589

12583-
The `execute` function runs an XCM message locally using the caller's origin. This is useful for executing XCM instructions that don't require cross-chain communication.
12590+
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.
1258412591

12585-
To execute a message:
12592+
Follow these steps to execute a message:
1258612593

12587-
1. Call `callWeighMessage` with your XCM message to get the required weight
12588-
2. Use the returned weight values when calling `callXcmExecute`
12594+
1. Call `callWeighMessage` with your XCM message to get the required weight.
12595+
2. Use the returned weight values when calling `callXcmExecute`.
1258912596
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:
1259012597

1259112598
- `message`: The encoded XCM message bytes.
1259212599
- `weight`: The `Weight` struct returned from `callWeighMessage`.
1259312600

12594-
You can examine the complete extrinsic structure for this operation [here](https://dev.papi.how/extrinsics#networkId=localhost&endpoint=wss%3A%2F%2Ftestnet-passet-hub.polkadot.io&data=0x1f03050c000401000003008c86471301000003008c8647000d010101000000010100368e8759910dab756d344995f1d3c79374ca8f70066d3a709e48029f6bf0ee7e0750c61e2901daad0600){target=\_blank}.
12601+
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.
1259512602

1259612603
5. Click on the **Transact** button to execute the xcm message:
1259712604

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

12600-
If successful, you will see the following output in the Remix terminal:
12607+
If successful, you will see the following output in the Remix terminal:
1260112608

12602-
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-07.webp)
12609+
![](/images/develop/smart-contracts/precompiles/xcm-precompile/xcm-precompile-07.webp)
1260312610

1260412611
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.
1260512612

1260612613
### Send a Message
1260712614

12608-
The `send` function transmits an XCM message to a destination chain. This is the core functionality for cross-chain communication.
12615+
The `send` function is responsible for transmitting an XCM message to a destination chain, enabling essential cross-chain communication.
1260912616

1261012617
To send a message:
1261112618

12612-
1. Prepare your destination location encoded in XCM format
12613-
2. Prepare your XCM message (similar to the execute example)
12614-
3. Call `callXcmSend` with both parameters
12619+
1. Prepare your destination location encoded in XCM format.
12620+
2. Prepare your XCM message (similar to the execute example).
12621+
3. Call `callXcmSend` with both parameters.
1261512622

1261612623
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.
1261712624

12618-
Unlike `execute`, the `send` function doesn't require a weight parameter since the destination chain will handle execution costs according to its own fee structure.
12625+
Unlike `execute`, the `send` function doesn't require a weight parameter since the destination chain will handle execution costs according to its fee structure.
1261912626

1262012627
## Cross Contract Calls
1262112628

12622-
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 seamlessly embed cross-chain capabilities into your application logic.
12629+
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.
1262312630

1262412631
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.
1262512632

0 commit comments

Comments
 (0)