#
pezkuwi_sdk_docs/pezkuwi_sdk/
xcm.rs

    1//! # XCM
    2//!
    3//! XCM, or Cross-Consensus Messaging, is a **language** to communicate **intentions** between
    4//! **consensus systems**.
    5//!
    6//! ## Overview
    7//!
    8//! XCM is a standard, specification of which lives in the [xcm format repo](https://github.com/pezkuwichain/pezkuwi-fellows/xcm-format).
    9//! It's agnostic both in programming language and blockchain platform, which means it could be used
    10//! in Rust in Pezkuwi, or in Go or C++ in any other platform like Cosmos or Ethereum.
    11//!
    12//! It enables different consensus systems to communicate with each other in an expressive manner.
    13//! Consensus systems include blockchains, smart contracts, and any other state machine that
    14//! achieves consensus in some way.
    15//!
    16//! XCM is executed on a virtual machine called the XCVM.
    17//! Scripts can be written with the XCM language, which are often called XCMs, messages or XCM
    18//! programs. Each program is a series of instructions, which get executed one after the other by
    19//! the virtual machine. These instructions aim to encompass all major things users typically do in
    20//! consensus systems. There are instructions on asset transferring, teleporting, locking, among
    21//! others. New instructions are added and changes to the XCVM are made via the [RFC process](https://github.com/paritytech/xcm-format/blob/master/proposals/0032-process.md).
    22//!
    23//! ## In Pezkuwi SDK
    24//!
    25//! The Pezkuwi SDK allows for easily deploying sovereign blockchains from scratch, all very
    26//! customizable. Dealing with many heterogeneous blockchains can be cumbersome.
    27//! XCM allows all these blockchains to communicate with an agreed-upon language.
    28//! As long as an implementation of the XCVM is implemented, the same XCM program can be executed in
    29//! all blockchains and perform the same task.
    30//!
    31//! ## Implementation
    32//!
    33//! A ready-to-use Rust implementation lives in the [pezkuwi-sdk repo](https://github.com/pezkuwichain/pezkuwi-sdk/tree/main/pezkuwi/xcm),
    34//! but will be moved to its own repo in the future.
    35//!
    36//! Its main components are:
    37//! - [`xcm`](::xcm): The definition of the basic types and instructions.
    38//! - [`xcm_executor`]: An implementation of the virtual machine to execute instructions.
    39//! - [`pezpallet_xcm`]: A FRAME pezpallet for interacting with the executor.
    40//! - [`xcm_builder`]: A collection of types to configure the executor.
    41//! - [`xcm_pez_simulator`]: A playground for trying out different XCM programs and executor
    42//!   configurations.
    43//!
    44//! ## Example
    45//!
    46//! To perform the very usual operation of transferring assets, the following XCM program can be
    47//! used:
    48#![doc = docify::embed!("src/pezkuwi_sdk/xcm.rs", example_transfer)]
    49//!
    50//! ## Get started
    51//!
    52//! To learn how it works and to get started, go to the [XCM docs](xcm_pez_docs).
    53
    54#[cfg(test)]
    55mod tests {
    56	use xcm::latest::prelude::*;
    57
    58	#[docify::export]
    59	#[test]
    60	fn example_transfer() {
    61		let _transfer_program = Xcm::<()>(vec![
    62			WithdrawAsset((Here, 100u128).into()),
    63			BuyExecution { fees: (Here, 100u128).into(), weight_limit: Unlimited },
    64			DepositAsset {
    65				assets: All.into(),
    66				beneficiary: AccountId32 { id: [0u8; 32].into(), network: None }.into(),
    67			},
    68		]);
    69	}
    70}