โ† Writing

๐ŸŽฎ Game on Solana: Guess the Number

2025-03-07 rust ยท solana ยท anchor ยท project


A simple interactive number guessing game powered by smart contracts on the Solana blockchain. Developed with Rust and the Anchor framework.


๐Ÿ“š GitHub Repository

This project showcases a minimalist on-chain game built using Anchor on the Solana blockchain. It combines basic game logic with decentralized infrastructure, allowing players to interact with a smart contract that โ€œthinks ofโ€ a number โ€” and challenges them to guess it.

A great demo for:


โš™๏ธ Stack


โœจ Features

  1. On-chain Random Number Generation

    • The program stores a secret number within its state (pseudo-random for now).
  2. Guess by Transaction

    • Users guess the number by sending a transaction with their attempt.
  3. Immediate Response

    • Program replies whether the guess is too low, too high, or correct.
  4. Stateless Client

    • All game logic and storage is managed on-chain; the client just sends guesses.

๐Ÿš€ Getting Started

1. ๐Ÿ”ง Start the Local Validator

Launch the Solana test environment locally:

solana-test-validator

2. ๐Ÿ› ๏ธ Build and Deploy the Program

Compile and deploy the Anchor smart contract:

anchor build && anchor deploy

3. ๐ŸŽฎ Play the Game

Send transactions with your guess to the validator. Example:

anchor run guess -- --number 42

This assumes youโ€™ve set up a client command/script to interact with the program using Anchor CLI or custom JS/TS scripts.


๐Ÿง  How It Works


๐Ÿ“„ License

This project is open-source and licensed under the MIT License โ€” feel free to build upon, modify, or expand.