A decentralized number guessing game built on the IOTA blockchain network. Players need to guess 4 secret numbers correctly to receive a Flag NFT.
Contract Address
- Network: testnet
- Package ID:
0x3062c7a482e441a030860cf496ac40a1d2de08d0938d77154276b033cf985814 - Explorer: View on Explorer
- ๐ Connect IOTA wallet via IOTA dApp Kit
- ๐ฏ Submit your guess to the smart contract
- ๐ฆ Receive GuessBox NFT after each guess
- ๐ Get Flag NFT when guessing correctly
- โ๏ธ Fully on-chain, transparent and immutable
- ๐จ Modern UI with Tailwind CSS
- Frontend: Next.js 16, React 19, TypeScript
- Blockchain: IOTA Network (Devnet)
- Smart Contract: Move Language
- UI: Tailwind CSS, Radix UI
- Web3: @iota/dapp-kit, @iota/iota-sdk
- Node.js 18+
- IOTA CLI installed
- IOTA wallet (supporting IOTA dApp Kit)
- IOTA test tokens (for devnet)
git clone <repository-url>
cd GameGuess
npm install --legacy-peer-depsNote: Use
--legacy-peer-depsto avoid peer dependency conflicts between React 19 and other libraries.
npm run iota-deployAfter successful deployment, you'll receive a Package ID. Copy this ID!
Open lib/config.ts and replace PACKAGE_ID with your Package ID:
export const PACKAGE_ID = "0x..."; // Replace with your Package IDnpm run devOpen your browser and visit http://localhost:3000
- Connect Wallet: Click "Connect Wallet" and select your IOTA wallet
- Enter Guess: Input 4 numbers (each number from 0-255)
- Submit Guess: Click "Submit Guess" to send to blockchain
- Get GuessBox ID: After successful transaction, you'll receive a GuessBox object ID
- Check Result: Enter GuessBox ID and click "Check" to see the result
- Receive Flag: If correct, you'll receive a Flag NFT! ๐
module game_guess::guess {
// Struct storing player's guess
public struct GuessAttempt has store {
number1: u16,
number2: u16,
number3: u16,
number4: u16,
}
// NFT containing the guess
public struct GuessBox has key, store {
id: UID,
guess: GuessAttempt,
}
// Reward NFT when guessed correctly
public struct Flag has key, store {
id: UID,
user: address,
solved_at: u64,
}
}- Submit your guess with 4 numbers of type
u16(0-65535) - Creates a GuessBox NFT containing your guess
- GuessBox is transferred to your wallet address
- Checks if the guess is correct by comparing BCS encoding
- If correct: Creates and transfers Flag NFT to you
- If incorrect: Transaction fails with error
EIncorrectGuess
The smart contract uses BCS (Binary Canonical Serialization) for comparison:
- Your guess is serialized into bytes
- Compared with the secret hex string:
x"0a0014001e002800" - Correct answer: [10, 20, 30, 40]
GameGuess/
โโโ app/ # Next.js App Router
โ โโโ layout.tsx # Root layout with providers
โ โโโ page.tsx # Main page - Game UI
โ โโโ globals.css # Global styles
โโโ components/ # React components
โ โโโ Provider.tsx # IOTA providers (QueryClient, WalletProvider)
โโโ contract/ # Smart contracts
โ โโโ game_guess/
โ โโโ sources/
โ โ โโโ game_guess.move # Move smart contract
โ โโโ Move.toml # Move package config
โ โโโ build/ # Compiled contract (auto-generated)
โโโ hooks/ # Custom React hooks
โ โโโ useContract.ts # Hook for contract interaction
โโโ lib/ # Utilities
โ โโโ config.ts # Configuration (PACKAGE_ID, network, etc.)
โโโ scripts/ # Scripts
โ โโโ iota-deploy-wrapper.js # Contract deployment script
โ โโโ iota-generate-prompt-wrapper.js
โโโ next.config.ts # Next.js config
โโโ tailwind.config.ts # Tailwind config
โโโ package.json # Dependencies
# Development
npm run dev # Run dev server
# Build
npm run build # Build for production
npm run start # Run production server
# Smart Contract
npm run iota-deploy # Deploy contract to IOTA network
# Linting
npm run lint # Run ESLintnpm install --legacy-peer-deps- Make sure you've run
npm run iota-deploy - Check if
PACKAGE_IDinlib/config.tsis correct - Verify you're connected to the correct network (devnet)
- Ensure your wallet has enough IOTA test tokens
- Get test tokens from IOTA Devnet Faucet
- Double-check the answer: 10, 20, 30, 40 (not 7, 13, 42, 99)
- Make sure the number order is correct
- Verify the GuessBox ID is accurate
The answer consists of 4 special numbers:
- ๐ข Nice round numbers
- ๐ Following an increasing pattern
- ๐ฏ Within the range 0-255
- ๐ Encoded as:
x"0a0014001e002800"
Answer: [10, 20, 30, 40] ๐
- โ Smart contract written in Move - a resource-safe language
- โ Answer is encoded in bytecode, not easily readable
- โ Uses BCS serialization for validation
- โ No backdoors or admin functions
โ ๏ธ This is a demo dApp on testnet, not for production use
MIT License - See LICENSE file for more details
This project was created as a demo to learn how to build dApps on the IOTA blockchain.
Have fun playing! ๐ฎ๐