An exploration of Polkadot’s cross-consensus communication format and the latest features of XCM v3.
XCM is Polkadot’s standard for cross-chain and cross-consensus communication.
It’s a messaging format used to exchange arbitrary data between chains, and is effectively a language used by developers to compose applications that span different blockchains, smart contract platforms, and Substrate pallets.
In less than a year, XCM has transformed the Polkadot network into an ecosystem of dynamic, interconnected projects that can collaborate with each other while benefiting from Polkadot’s shared security umbrella.
And because it is cross-consensus, XCM can be used not just within the security umbrella of the Polkadot Relay Chain and its attached parachains, but also over bridges to external networks like Kusama (Polkadot's canary network) and Ethereum. It even connects different smart contract systems. For example, a smart contract built on an Ethereum EVM platform can communicate with a smart contract on a WebAssembly-based (Wasm) platform using Polkadot’s native ink! smart contract language.
Parachains across the Polkadot ecosystem have adopted XCM for a range of cross-chain use cases, opening over 100 channels and sending an impressive 10,000 messages in the first month that XCM went live. To date, over half a million XCM messages have been sent on Polkadot and Kusama combined.
With the release of XCM v3, XCM’s latest version, several important new features will be unlocked, including bridging to external networks, NFT exchanges, improved programmability, and more.
What is XCM and why does Web3 need it?
XCM stands for cross-consensus messaging. It's a format that defines what kind of data is transferred during communications between chains, and how they should be interpreted.
It aims to be a language communicating ideas between different consensus systems, and can involve both fee-free and gas-metered smart contract platforms. By cross-consensus, we mean that XCM is a generic, universal language that makes no assumptions about a particular consensus system, and thus can be used between any participating blockchain, smart contract system, runtime pallet, etc. XCM is extensible, future-proof, and highly efficient.
A crucial innovation for Web3, XCM ends the era of siloed networks, a limitation of previous-generation technology that made blockchain impractical or insufficient for many use cases. The siloed nature of previous networks was a significant barrier to user adoption and retention, and a major limitation for product development, leading to increased time to market and missed opportunities for innovation.
Without the crucial interoperability brought by XCM, the decision of which network to deploy a project on represented a serious risk, locking businesses into platforms where they can lose out on opportunities to partner with other businesses and integrate innovative technologies on other platforms.
Not only does XCM unlock cross-chain exchange of data and assets, it also enables powerful cross-chain integrations. Similar to how applications in Web2 could integrate services developed by others, thereby reducing development and maintenance overhead and increasing time to market, XCM enables applications across the Polkadot ecosystem and beyond to tap into Web3 services on blockchains that are optimized for specific use cases.
XCM used between chains and dapps built on Polkadot also enables secure, trustless interoperability on a level that has not been previously possible. With previous-generation cross-chain technology on other networks, assets were left vulnerable to hacks and double spending through centralized, insecure bridges, with losses topping $2.5 billion in 2022 alone.
What does XCM enable?
Because XCM allows blockchains to communicate with each other, it also enables businesses and developers on different chains to collaborate on projects, build applications that span several chains, or even create multichain DAOs (decentralized autonomous organizations).
For example, a decentralized application (or dapp) built on one chain could integrate an asset from another chain.
XCM can also provide a method for various token transfer models, including:
- Remote Transfers: controlling an account on a remote chain, such that chain A has an address on chain B for receiving funds and to eventually transfer those funds it controls into other accounts on chain B
- Teleporting: moving an asset, such as an NFT, by destroying it on one chain and creating a clone on the other chain.
XCM transport protocols: HRMP, XCMP, & VMP
While XCM is a format and a language for programming cross-chain applications, it is not a messaging protocol. XCM relies on transport protocols like HRMP, XCMP and VMP to exchange XCM messages from one system to another, plus external Bridges.
HRMP (Horizontal Relay-routed Message Passing), also known as XCMP-lite, is the first live iteration of cross-parachain messaging within the Polkadot network.
HRMP comes with all the functionality of XCMP, but is more demanding on resources because it passes all messages via the Relay Chain. HRMP will be deprecated when the full XCMP is released.
XCMP (Cross-Chain Message Passing) allows cross-chain transactions to be resolved using a simple queuing mechanism. It is the task of the Relay Chain validators to move transactions on the output queue of one parachain into the input queue of the destination parachain. The associated metadata is stored as a hash in the Relay Chain storage.
Full XCMP is an in-development upgrade from HRMP/XCMP-lite, making the process more scalable and eliminating the requirement for a governance process to open channels between individual chains.
VMP (Vertical Message Passing) comes into play when the Relay Chain itself is involved either as a sender or recipient. It allows parachains to be either the sender or recipient of a message in which the other party is the Relay Chain.
Bridges: While XCM is typically considered from the standpoint of parachains and their own intercommunications, the technology also allows for transportation beyond the Polkadot ecosystem, hence bringing into play its cross-consensus capabilities.
With XCM v3, XCM is well on the way to realizing its full potential, with several key advancements over v2, released in 2022.
Key among the latest upgrades is the ability to use XCM over bridges to external ecosystems. This will include but is not limited to bridges currently in development for connecting Polkadot and its parachains to the Kusama and Ethereum networks.
This even enables multi-hop setups where XCM messages can travel over multiple bridges in a single operation thanks to the addition of a new junction, GlobalConsensus, that allows destinations to be specified across virtually any blockchain ecosystem.
XCM v3 also enables further asset exchanges, and in particular cross-chain NFT functionality, and improved programmability features, including expectations, conditionals, contest tracking, and branching, so XCM messages can be programmed to behave in different ways on destination chains. For example, a message can be programmed to carry out different operations in response to an error message or return a confirmation that some activity took place on the destination chain.
Another key programmability feature included with XCM v3 is remote locking, which allows one chain to request that an asset be locked on another chain. This is a crucial interoperability feature enabling blockchains to make use of assets that exist on other chains.
XCM v3 also sets the stage for multichain decomposition, the process of moving key Polkadot functionality out of the Relay Chain and into system parachains instead. Rather than performing key functions, the Relay Chain is intended to simply relay messages. Staking can, for example, be requested on one parablock chain and carried out on another optimized parablock chain, saving bandwidth and preventing other operations from being clogged.
Unlocking the true multichain future
With XCM reaching full functionality, the multichain future outlined in the original vision for Polkadot can truly begin.
For builders, XCM represents a major leap forward in product development, giving teams the competitive advantage over siloed services and increasing time to market by eliminating the need to reinvent the wheel for every new piece of functionality a project needs to integrate. Web3 services can now be built in a more agile, modular way by tapping into powerful cross-chain integrations. This enables builders to stay on top of the innovation curve with faster product iteration cycles and decreased maintenance overhead. Thanks to XCM, businesses can also mitigate the risk of choosing a Web3 platform that doesn’t embrace native interoperability, helping them avoid the pitfalls of platform lock-in.
For Web3 users, XCM will lead to improved user experience by eliminating the boundaries between networks, ensuring that their self-sovereign data and assets can be used to access services no matter which blockchain they exist on. Ultimately, XCM enables unmatched security for an interoperable Web3, avoiding the ‘weakest link’ problem presented by previous-generation interoperability technologies.
Is your project ready to take advantage of the next wave of interoperable Web3 innovation? Read more about the technical details of XCM on the Polkadot Wiki.
Interested in developing for or building on Polkadot? Get in touch for hands-on support.
From the blog
Elevating Polkadot's Performance and Scale with Asynchronous Backing
Asynchronous backing is the latest step in the roadmap towards natively scaling Polkadot’s performance and flexibility for Web3 use cases across every industry.