project screenshot 1
project screenshot 2
project screenshot 3

On-Chain Maze Runner

The on-chain maze runner is a decentralized game on Ethereum where players navigate through dynamic mazes, aiming to reach the finish line while leveraging blockchain technology for transparency and security.

On-Chain Maze Runner

Created At

Autonomous Worlds

Project Description

Project Title: On-Chain Maze Runner

Project Description: The on-chain maze runner project is a decentralized and interactive game built on the Ethereum blockchain. The goal of the project is to provide users with an immersive gaming experience where they navigate through a maze and try to reach the finish line.

When a user starts the game, a unique maze is generated on the blockchain using a randomized algorithm. The maze is represented as a grid of cells, where each cell can be either a wall or an open path. The maze generation process ensures that the maze is solvable and offers a challenging gameplay experience.

The game interface is built using React, providing a visually appealing and user-friendly experience. Players can control their avatar within the maze using keyboard inputs or on-screen controls, depending on the device they are using. As the player moves through the maze, their current position is updated in real-time, allowing them to explore and navigate the maze efficiently.

The maze runner game incorporates both on-chain and off-chain components. The maze data, including the layout and player positions, is stored on the Ethereum blockchain using smart contracts written in Solidity. This ensures the integrity and transparency of the game logic, as all interactions are executed on the blockchain.

To provide a smooth and responsive gameplay experience, the game leverages off-chain technologies such as IPFS for storing the maze data and associated game assets. This allows players to quickly retrieve the necessary information without relying on a centralized server.

To interact with the game, players connect their Ethereum wallets, such as Metamask, to the application. This enables them to sign transactions and pay for the gas fees associated with interacting with the maze runner contract.

Throughout the game, players face the challenge of finding the optimal path to reach the finish line while avoiding dead ends and obstacles. Once a player successfully completes the maze and reaches the finish line, they are rewarded with points or tokens, depending on the specific implementation of the project.

The on-chain maze runner project combines the transparency and security of blockchain technology with an engaging and challenging gaming experience. By leveraging the decentralized nature of the Ethereum blockchain, the project ensures fairness and immutability, allowing players to enjoy a unique and tamper-proof gaming environment.

How it's Made

To build the on-chain maze runner project, I used the following technologies and pieced them together:

  1. Solidity: I used Solidity, a programming language for writing smart contracts, to implement the MazeRunner contract. Solidity allowed me to define the game logic, including maze generation, player movement, and finish line checking.

  2. Truffle: Truffle is a development framework that provides tools for compiling, testing, and deploying smart contracts. I used Truffle to manage the project structure, compile the contracts, and write tests.

  3. Web3.js: Web3.js is a JavaScript library that interacts with Ethereum and allows communication with smart contracts. I used Web3.js in the frontend of the project to connect to the Ethereum network, interact with the MazeRunner contract, and fetch data from the blockchain.

  4. React: I used React, a popular JavaScript library for building user interfaces, to create the frontend of the maze runner game. React helped me create reusable components and manage the application state efficiently.

  5. HTML and CSS: I used HTML and CSS to structure and style the user interface of the maze runner game. HTML was used to define the page structure, while CSS was used for styling and layout.

  6. Metamask: Metamask is a browser extension that allows users to interact with Ethereum-based applications. I leveraged Metamask to provide a seamless and secure way for users to connect their Ethereum wallets to the game.

  7. Infura: Infura is a service that provides easy access to the Ethereum network infrastructure. I used Infura as a provider for Web3.js, allowing the maze runner game to connect to the Ethereum network without the need to run a local Ethereum node.

  8. IPFS: IPFS (InterPlanetary File System) is a decentralized storage protocol. I used IPFS to store the maze data and associated game assets, ensuring their availability and reliability without relying on a centralized server.

By incorporating these sponsor technologies into the project, I was able to enhance its functionality and user experience. Infura enabled seamless integration with the Ethereum network, ensuring smooth gameplay and interaction with the MazeRunner contract. IPFS provided a decentralized and resilient storage solution, allowing players to access the maze data and game assets reliably from any location.

In terms of notable and hacky implementations, one interesting feature I implemented was generating the maze on-chain using a randomized algorithm. This allowed for a unique maze to be generated for each game session and ensured fairness and transparency. By leveraging the blockchain's pseudo-randomness, I could create a deterministic and tamper-proof maze generation process.

Additionally, I implemented gas-efficient smart contract functions by carefully managing state changes and minimizing storage operations. This ensured that the game could be played smoothly and cost-effectively for the users.

Overall, the project combined the power of Solidity smart contracts, Truffle development tools, Web3.js for blockchain interaction, React for the user interface, and standard web technologies. The sponsor technologies, including Metamask, Infura, and IPFS, further enhanced the project by providing seamless Ethereum network integration and decentralized storage capabilities.

background image mobile

Join the mailing list

Get the latest news and updates