## Motivation `pallet-xcm` is the main user-facing interface for XCM functionality, including assets manipulation functions like `teleportAssets()` and `reserve_transfer_assets()` calls. While `teleportAsset()` works both ways, `reserve_transfer_assets()` works only for sending reserve-based assets to a remote destination and beneficiary when the reserve is the _local chain_. ## Solution This PR enhances `pallet_xcm::(limited_)reserve_withdraw_assets` to support transfers when reserves are other chains. This will allow complete, **bi-directional** reserve-based asset transfers user stories using `pallet-xcm`. Enables following scenarios: - transferring assets with local reserve (was previously supported iff asset used as fee also had local reserve - now it works in all cases), - transferring assets with reserve on destination, - transferring assets with reserve on remote/third-party chain (iff assets and fees have same remote reserve), - transferring assets with reserve different than the reserve of the asset to be used as fees - meaning can be used to transfer random asset with local/dest reserve while using DOT for fees on all involved chains, even if DOT local/dest reserve doesn't match asset reserve, - transferring assets with any type of local/dest reserve while using fees which can be teleported between involved chains. All of the above is done by pallet inner logic without the user having to specify which scenario/reserves/teleports/etc. The correct scenario and corresponding XCM programs are identified, and respectively, built automatically based on runtime configuration of trusted teleporters and trusted reserves. #### Current limitations: - while `fees` and "non-fee" `assets` CAN have different reserves (or fees CAN be teleported), the remaining "non-fee" `assets` CANNOT, among themselves, have different reserve locations (this is also implicitly enforced by `MAX_ASSETS_FOR_TRANSFER=2`, but this can be safely increased in the future). - `fees` and "non-fee" `assets` CANNOT have **different remote** reserves (this could also be supported in the future, but adds even more complexity while possibly not being worth it - we'll see what the future holds). Fixes https://github.com/paritytech/polkadot-sdk/issues/1584 Fixes https://github.com/paritytech/polkadot-sdk/issues/2055 --------- Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Contracts 📝
This is a parachain node for smart contracts; it contains a default configuration of
Substrate's module for smart contracts ‒ the pallet-contracts.
The node is only available on Rococo, a testnet for Polkadot and Kusama parachains.
It has been configured as a common good parachain, as such it uses the Rococo relay
chain's native token ROC instead of defining a token of its own.
See the section Rococo Deployment below for more details.
If you have any questions, it's best to ask in the Substrate StackExchange.
Smart Contracts Development
This node contains Substrate's smart contracts module ‒ the
pallet-contracts.
This pallet takes smart contracts as WebAssembly blobs and defines an API
for everything a smart contract needs (storage access, …).
As long as a programming language compiles to WebAssembly and there exists an implementation
of this API in it, you can write a smart contract for this pallet (and thus for this parachain)
in that language.
This is a list of languages you can currently choose from:
- Parity's ink! for Rust.
- ask! for Assembly Script.
- The Solang compiler for Solidity.
There are also different user interfaces and command-line tools you can use to deploy or interact with contracts:
- Contracts UI ‒ a beginner-friendly UI for smart contract developers.
polkadot-js‒ the go-to expert UI for smart contract developers.cargo-contract‒ a CLI tool, ideal for scripting or your terminal workflow.
If you are looking for a quickstart, we can recommend ink!'s Guided Tutorial for Beginners.
Build & Launch a Node
To run a Contracts node that connects to Rococo
you will need to compile the polkadot-parachain binary:
cargo build --release --locked --bin polkadot-parachain
Once the executable is built, launch the parachain node via:
./target/release/polkadot-parachain --chain contracts-rococo
Refer to the setup instructions to run a local network for development.
Rococo Deployment
We have a live deployment on Rococo ‒ a testnet for Polkadot and Kusama parachains.
You can interact with the network through Polkadot JS Apps, click here for a direct link to the parachain.
This parachain uses the Rococo relay chain's native token ROC instead of defining a token of its own.
Due to this you'll need ROC in order to deploy contracts on this parachain.
As a first step, you should create an account. See here for a detailed guide.
As a second step, you have to get ROC testnet tokens through the Rococo Faucet.
This is a chat room in which you'd need to post the following message:
!drip YOUR_SS_58_ADDRESS:1002
The number 1002 is the id of this parachain on Rococo, by supplying it the faucet will teleport ROC
tokens directly to your account on the parachain.
If everything worked out, the teleported ROC tokens will show up under
the "Accounts" tab.
Once you have ROC you can deploy a contract as you would normally.
If you're unsure about this, our guided tutorial
will clarify that for you in no time.