Magic Number Game Docs
  • Magic Number Game & MNG Token
Powered by GitBook
On this page
  • Table of Contents
  • 1. Introduction
  • What is the Magic Number Game?
  • How Does It Work?
  • Why is it Fair?
  • What is the MNG Token?
  • 2. Game Mechanics
  • Step-by-Step Gameplay
  • How Winners Are Chosen
  • 3. MNG Token Utility
  • Tokenomics
  • 4. Smart Contract Architecture
  • Main Components
  • 5. Security & Trust
  • Security Features
  • 6. Deployment Guide
  • Prerequisites
  • Deployment Steps
  • 7. API & Smart Contract Interaction
  • Main Functions
  • 8. Future Enhancements & Roadmap
  • Upcoming Features

Magic Number Game & MNG Token

Table of Contents

1. Introduction

2. Game Mechanics

3. MNG Token Utility

4. Smart Contract Architecture

5. Security & Trust

6. Deployment Guide

7. API & Smart Contract Interaction

8. Future Enhancements & Roadmap

1. Introduction

The Magic Number Game is an Ethereum-based blockchain game utilizing smart contracts and Chainlink VRF for provable randomness. It allows players to guess a number, pay an entry fee, and compete for rewards in ETH and MNG tokens. This document explains how the game works and provides an in-depth technical breakdown of its implementation.

What is the Magic Number Game?

Magic Number Game is a decentralized number guessing game where players enter a guess and pay a small entry fee. A Chainlink VRF-generated random number determines the winner, ensuring fairness.

How Does It Work?

1. Players enter the game by submitting a guess and paying 0.025 ETH. 2. When three players have entered, the game requests a random number using Chainlink VRF. 3. The closest guess wins the prize pool, and all players receive MNG tokens as rewards. 4. The game resets, allowing new players to join.

Why is it Fair?

The game is completely fair due to its integration with Chainlink VRF, which provides a tamper-proof and publicly verifiable random number. The smart contract automatically distributes rewards without human intervention.

What is the MNG Token?

MNG is the reward token for the Magic Number Game. Players receive MNG for participating, and winners receive additional rewards. The token has a fixed supply of 21 million, and rewards halve every 3,500 games.

2. Game Mechanics

The game operates on a simple mechanism designed to be engaging and fair.

Step-by-Step Gameplay

1. A player submits a guess between 1 and 10,000. 2. They pay an entry fee of 0.025 ETH. 3. When three players have joined, the contract requests a random number. 4. The winner is the player with the closest guess. 5. The winner receives the ETH prize, and all players receive MNG tokens. 6. The game resets for the next round.

How Winners Are Chosen

The smart contract uses the Chainlink VRF to generate a random number. The player with the closest guess wins the ETH prize. In case of a tie, the prize is split equally among winners.

3. MNG Token Utility

The MNG token serves as the in-game reward currency. Players earn MNG for participating, and winners receive bonus MNG.

Tokenomics

Total Supply: 21,000,000 MNG Player Reward: 50 MNG per game Winner Bonus: 500 MNG per win Halving Cycle: Every 3,500 games, the rewards are halved. 1M MNG is reserved for development and game incentives.

4. Smart Contract Architecture

The smart contract handles game logic, rewards distribution, and random number generation. It is built using Solidity and deployed on the Ethereum blockchain.

Main Components

- **Game Logic**: Handles player entries, winner selection, and prize distribution. - **Chainlink VRF**: Generates provably fair random numbers. - **MNG Token**: ERC-20 token used for player rewards. - **Security**: Includes reentrancy protection and gas efficiency optimizations.

5. Security & Trust

Security is critical in smart contract development. The Magic Number Game is designed with multiple layers of security.

Security Features

- **Chainlink VRF** ensures unbiased randomness. - **ReentrancyGuard** prevents reentrancy attacks. - **Require statements** validate all inputs. - **No manual intervention** – rewards are distributed automatically.

6. Deployment Guide

To deploy the game and MNG token, follow these steps:

Prerequisites

- Install Node.js and Hardhat - Have ETH for gas fees - Deploy on Ethereum or a testnet

Deployment Steps

1. Compile the contract using Hardhat. 2. Deploy the MNG token contract. 3. Deploy the game contract with the correct token address. 4. Verify the contract on Etherscan.

7. API & Smart Contract Interaction

Developers can interact with the smart contract using Web3.js or Ethers.js.

Main Functions

- **enterGuess(uint256 _guess)**: Allows players to submit their guess. - **requestRandomNumber()**: Calls Chainlink VRF to generate a random number. - **distributeRewards()**: Automatically distributes ETH and MNG rewards. - **resetGame()**: Resets the game for the next round.

8. Future Enhancements & Roadmap

The game will continue to evolve with new features and optimizations.

Upcoming Features

- **Leaderboard**: Track top players based on winnings. - **NFT Integration**: Players can earn NFT rewards. - **Governance**: Community voting for game updates. - **Multi-chain Expansion**: Deploy on multiple blockchains.

Last updated 3 months ago