referrerpolicy=no-referrer-when-downgrade

xcm_docs/cookbook/relay_token_transactor/
mod.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
3// This file is part of Polkadot.
4
5// Polkadot is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9
10// Polkadot is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14
15// You should have received a copy of the GNU General Public License
16// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
17
18//! # Relay Asset Transactor
19//!
20//! This example shows how to configure a parachain to only deal with the Relay Chain token.
21//!
22//! The first step is using the [`xcm_builder::FungibleAdapter`] to create an `AssetTransactor` that
23//! can handle the relay chain token.
24#![doc = docify::embed!("src/cookbook/relay_token_transactor/parachain/xcm_config.rs", asset_transactor)]
25//!
26//! The second step is to configure `IsReserve` to recognize the relay chain as a reserve for its
27//! own asset.
28//! With this, you'll be able to easily mint a derivative asset, backed one-to-one from the Relay
29//! Chain, by using the xcm pallet's `transfer_assets` extrinsic.
30//!
31//! The `IsReserve` type takes a type that implements `ContainsPair<MultiAsset, MultiLocation>`.
32//! In this case, we want a type that contains the pair `(relay_chain_native_token, relay_chain)`.
33#![doc = docify::embed!("src/cookbook/relay_token_transactor/parachain/xcm_config.rs", is_reserve)]
34//!
35//! With this setup, we are able to do a reserve asset transfer to and from the parachain and relay
36//! chain.
37#![doc = docify::embed!("src/cookbook/relay_token_transactor/tests.rs", reserve_asset_transfers_work)]
38//!
39//! For the rest of the code, be sure to check the contents of this module.
40
41/// The parachain runtime for this example
42pub mod parachain;
43
44/// The relay chain runtime for this example.
45pub mod relay_chain;
46
47/// The network for this example.
48pub mod network;
49
50/// Tests for this example.
51#[cfg(test)]
52pub mod tests;