project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6

Linkagotchi

Blockchain-powered virtual pets meet nostalgia! Create and evolve unique NFT creatures. With Chainlink VRF for true randomness, on-chain ranking, and a retro UI, it's a Web3 twist on the classic Tamagotchi. Nurture your digital companion anywhere!

Linkagotchi

Created At

ETHOnline 2024

Project Description

Linkagotchi is an blockchain-based virtual pet game that reimagines the classic Tamagotchi concept for the Web3 era. Built on the Ethereum Sepolia network, Linkagotchi allows players to create, nurture, and evolve unique digital creatures, called Blockagotchis, as NFTs (Non-Fungible Tokens). Key Features:

Unique Digital Pets: Each Blockagotchi is a one-of-a-kind NFT with its own characteristics, including race, stage, and the potential to be a rare "shiny" variant. There is also a limit of 100 eggs that can be hatched, they also have a rare trait "origin".

Evolution System: Blockagotchis evolve through different stages (Blob, Child, Teen, Adult, Old) based on player interactions and experience gained. On certain stages, their race also changes, giving them a totally different look.

Chainlink VRF Integration: Utilizes Chainlink's Verifiable Random Function (VRF) to ensure fair and transparent generation of Blockagotchi rarity. This is essential for generating shiny blockagotchi (1/8192 chance)

On-Chain Game Logic: All game mechanics, including pet creation, evolution, and action outcomes, are executed entirely on the blockchain, ensuring transparency and immutability.

Interactive Gameplay: Players can perform various actions like feeding, bathing, and exercising their Blockagotchis, each affecting the pet's happiness, health, and experience. Global Ranking System: An on-chain leaderboard tracks the top Linkagotchis based on a score calculated from experience, happiness, and age. Retro-Style UI: The game features a nostalgic, NES-inspired user interface, making it visually appealing and user-friendly. Full Ownership: As NFTs, players truly own their Blockagotchis, with the potential for future trading or use in other blockchain ecosystems.

Technical Aspects:

Smart Contracts: Written in Solidity, leveraging the ERC721 standard for NFTs. Frontend: Developed using React for a responsive and interactive user experience. Blockchain Interaction: Utilizes ethers.js for seamless communication with the Ethereum network. Randomness: Implements Chainlink VRF for provably fair random number generation.

Future Potential: The current implementation lays a strong foundation for future expansions, including pet battles, a marketplace for trading Blockagotchis and in-game items, and integration with other blockchain games or platforms. And of course, tokennomics. Linkagotchi combines the nostalgic appeal of virtual pets with the cutting-edge technology of blockchain, creating an engaging, transparent, and truly owned digital pet experience. It serves as both an entertaining game and an accessible entry point into blockchain technology and NFTs for new users.

How it's Made

So, here is how i designed and developed the whole project. Lets go in detail to all technologies:

Core Technologies:

Solidity (v0.8.19): Used for writing smart contracts, leveraging the latest features for efficient and secure on-chain logic. OpenZeppelin Contracts: Utilized for implementing the ERC721 standard, ensuring our NFTs are compliant and interoperable. Chainlink VRF (Verifiable Random Function): Integrated for generating truly random and verifiable outcomes for pet creation and rare trait allocation. React: Employed for building a responsive and interactive frontend. ethers.js: Used for seamless interaction between the frontend and the Ethereum blockchain. NES.css: Implemented for a nostalgic, 8-bit style UI design.

Smart Contract Architecture:

The main Linkagotchi contract inherits from ERC721 and VRFConsumerBaseV2Plus. Key structs and enums define Blockagotchi properties (Stage, Race, etc.). Mappings are used for efficient data storage and retrieval. Custom functions handle pet creation, evolution, action performance, and ranking updates.

Chainlink VRF Integration:

I have implemented in the pet creation process to ensure fair and verifiable randomness. Uses a subscription-based model for cost-effective random number generation. The fulfillRandomWords function processes the VRF result to create unique Blockagotchis. With that, the shiny blockagotchi generations are totally random and fair.

On-Chain Game Logic:

All game mechanics (e.g., performAction, updateStage, evolveRace) are implemented entirely on-chain. This approach ensures full transparency and immutability of game rules.

Frontend Development:

React components handle different aspects of the UI (e.g., BlockagotchiRanking, CustomAlert). State management using React hooks (useState, useEffect) for responsive UI updates. Asynchronous calls to the smart contract are managed using ethers.js.

Responsive Design:

CSS modules and media queries ensure the game is playable on various device sizes. NES.css provides a consistent retro feel across the application.

Notable Implementations:

Dynamic Sprite Animations: Implemented using CSS animations, changing based on Blockagotchi actions and states. On-Chain Ranking System: Leaderboard is maintained entirely on-chain, updating in real-time as players interact with their pets. Shiny Blockagotchi Feature: Rare variant (Shiny) are determined by VRF, with special visual effects on the frontend.

Challenges and Solutions:

Optimizing gas costs for on-chain operations was crucial. We implemented efficient data structures and optimized function calls to minimize gas usage. Ensuring synchronization between blockchain state and frontend display required careful management of asynchronous operations and state updates.

Future-Proofing:

The contract is designed with upgradeability in mind, allowing for future feature additions without disrupting existing gameplay. The modular frontend design allows for easy integration of new features and UI components.

By leveraging these technologies and implementing game logic on-chain, Linkagotchi achieves a unique blend of blockchain transparency, verifiable randomness, and nostalgic gameplay, creating an engaging and innovative virtual pet experience in the Web3 space. Even though most of it is on a Toy/PoC stage, everything can be evolved to a new completed approach.

background image mobile

Join the mailing list

Get the latest news and updates