Cross-chain game: Battle enemies, earn rewards, trade resources on a fully onchain economy
Aetheria is a fully cross-chain blockchain game that demonstrates the power of LayerZero V2's omnichain infrastructure. Players own NFTs that can battle enemies across different chains, creating a seamless multi-chain gaming experience. Core Gameplay Loop: Players send their NFTs from Base Sepolia to battle chains (Arbitrum or Optimism Sepolia), where they encounter enemies and enter an autmated battle. After each battle, the NFT automatically returns to the player, and rewards are minted on Base and sent cross-chain to the player's wallet—5 energy tokens for wins, 2 tokens for losses and game state recorded on hub chain. Cross-Chain Economy: The energy token (OFT) serves dual purposes: as a reward currency and as fuel for the resource economy. Players can burn energy tokens at a 1:1 ratio to mint resources like Ore or Wood, which are also cross-chain OFT tokens. This creates an interesting economic decision: save energy for trading or convert it to resources. Decentralized Marketplace: Resources can be listed for sale on the Base Sepolia marketplace by sending them cross-chain using LayerZero's lzCompose feature. The marketplace operates at a fixed rate of 2 energy = 1 resource, creating a simple yet functional trading system. Sellers receive energy payments and can withdraw their proceeds at any time. Technical Innovation: Aetheria leverages LayerZero V2's advanced features including ONFT (Omnichain NFTs) with compose messages, OFT (Omnichain Fungible Tokens), and cross-chain message passing. The battle logic uses lzCompose to trigger automatic battles when NFTs arrive on battle chains, and the hub contract coordinates cross-chain reward distribution using OFT's built-in send functionality. Why It Matters: This project showcases how blockchain games can transcend single-chain limitations, creating truly omnichain experiences where assets move freely between chains while maintaining game logic integrity. Players never worry about which chain they're on—the game handles all cross-chain complexity behind the scenes.
Aetheria is built on Solidity smart contracts deployed across Base Sepolia (hub), Arbitrum Sepolia, and Optimism Sepolia using Foundry and Hardhat. The frontend is a Next.js application using wagmi/viem for wallet integration and contract interactions. LayerZero V2 Integration: The core of the project leverages LayerZero V2's advanced features. I implemented ONFT721 (Omnichain NFT) for player characters with compose message capabilities, allowing automatic battle triggering when NFTs arrive on battle chains. The OFT (Omnichain Fungible Token) standard powers both the energy rewards and resource tokens, enabling seamless cross-chain transfers. lzCompose Architecture: This was a complicated A->B->C->B architecture. The most technically interesting aspect is the lzCompose flow. When a player sends an NFT to a battle chain, the ONFT's receive triggers lzCompose on the MyONFT721ComposerMock contract. This composer simulates a battle, sends the result to the AetheriaHub on Base via lzSend, and transfers the NFT back to the original sender—all automatically within the compose execution. Cross-Chain Reward Distribution: The AetheriaHub receives battle results and mints energy OFT tokens on Base, then immediately sends them cross-chain back to the player's wallet on their origin chain. This required careful handling of the OFT.send() function. OVault: Users can also leverage ovaults to generate yield on their resources ofts which opens up an onchain economy Marketplace Innovation: The ResourceOFTComposerMock implements a marketplace using OFT compose messages. When users send resource tokens cross-chain to the marketplace, lzCompose automatically creates a listing using the OFTComposeMsgCodec to decode the sender's address and token amount. This eliminates the need for separate "approve and list" transactions.

