# Use Case Example: Building a Multi-Layered dApp with XCM

To illustrate the transformative potential of Cross-Consensus Messaging (XCM) within the Glue ecosystem, consider the example of a complex multiplayer online game. This game leverages multiple L2s to optimise different aspects of its functionality, similar to how it is not efficient or good practice to deploy a piece of software on AWS using a single instance type (m4.4xl for example). Just as AWS users select instance types optimised for specific workloads to achieve scalability and efficiency, Glue's use-case optimised L2s provide tailored environments for different facets of a dApp.

### Gaming: A Multi-Layered Approach

Imagine a game that involves gameplay, asset issuance, and financial transactions. Each component of this game is hosted on a different L2, utilising Glue's XCM to ensure seamless interaction, better user experience and superior performance.

1.  #### **Game Logic on the Gaming L2**

    Performance: The game logic is hosted on the Gaming L2, which is optimised for throughput and low fees. This L2 is designed to handle high-frequency interactions of the gameplay, ensuring a smooth and responsive gaming experience without breaking the bank.

    Use Case Optimisation: By isolating the game logic on a specialised L2, the game can take full advantage of performance optimisations tailored for gaming applications. This reduces the load on other L2s and allows the game to scale efficiently.
2.  **Asset Issuance on the Asset Transfer L2**

    Cost-Effectiveness and Decentralisation: The game's assets, such as in-game currency, are issued on the Asset Transfer L2. This L2 is optimised for minting, burning, and transferring assets, offering a cost-effective and highly decentralised environment.

    Security: By using a specialised L2 for asset transfers, the game ensures that asset issuance and transfers are secure, efficient, and inexpensive. This L2 is designed to handle high volumes of transactions without incurring significant costs, making it ideal for managing digital assets.
3.  **Trading on the Finance L2**

    Financial Operations: The trading of in-game assets occurs on the Finance L2, which is optimised for DeFi applications. This L2 is fully EVM compatible and provides a high level of censorship resistance and transaction efficiency, ensuring secure and reliable trading.

    Economic Integration: By leveraging the Finance L2, the game can integrate advanced financial functionalities, such as market orders, auctions, and liquidity pools, enhancing the economic complexity and engagement within the game.

### Seamless Integration with XCM

XCM facilitates the seamless interaction between these specialised L2s, ensuring that the game operates as a cohesive and efficient system.

As players engage in gameplay on the Gaming L2, they can earn or acquire in-game assets. These assets are issued and managed on the Asset Transfer L2, with XCM enabling instant and secure communication between the two L2s. For example, when a player wins a battle and earns a rare token, the Gaming L2 sends a message via XCM to the Asset Transfer L2 to mint the new token and assign it to the player's account.

Players can trade their in-game assets on the Finance L2. XCM allows the Asset Transfer L2 to communicate with the Finance L2, facilitating the seamless transfer of assets for trading purposes. When a player lists an item for sale, the Asset Transfer L2 sends a message via XCM to the Finance L2, where the item is listed on a decentralised marketplace. Once the transaction is complete, the Finance L2 notifies the Asset Transfer L2 to update the ownership records.

<figure><img src="https://896423194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F37ainNYLJfxc4Gvn5BhT%2Fuploads%2FHYWlA6dhzNPc9Tx3nuIK%2FPicture%2011.png?alt=media&#x26;token=55e1ba10-56c4-4a67-8d70-fcf7019bbc97" alt=""><figcaption><p><em>Figure 11: The Glue platform, using XCM, facilitates seamless interaction between L2s, enabling the Game dApp to provide a comprehensive and efficient gaming experience to users. Gaming L2, optimised for speed and low latency, ensuring smooth gameplay. Asset Transfer L2, optimised for minting, burning, and transferring assets in a cost-effective and decentralised manner. Finance L2, allows integration of advanced financial functionalities like market orders, auctions, and liquidity pools.</em></p></figcaption></figure>

### Strategic Advantages of a Multi-Layered Approach

The multi-layered approach exemplified by this game showcases the strategic advantages of using Glue's use-case optimised L2s.

**Scalability and Performance**: By distributing different functions across specialised L2s, the game can scale efficiently without overburdening a single layer. Each L2 handles a specific aspect of the game, ensuring optimal performance and responsiveness.

**Cost Efficiency**: Using specialised L2s for different tasks reduces overall costs. The Asset Transfer L2, for example, handles high-volume transactions at a lower cost by not offering EVM compatibility, while the Finance L2 provides robust financial services with high levels of decentralisation.

**Improved User Experience**: The seamless integration facilitated by XCM ensures a smooth and engaging user experience. Players can interact with different aspects of the game without encountering delays or complexities, enhancing overall satisfaction and engagement.

**Flexibility and Innovation:** This approach allows for continuous innovation and flexibility. New features and functionalities can be introduced on specific L2s without disrupting the entire ecosystem, enabling the game to evolve and adapt to changing user needs and technological advancements.
