Skip to content

VijayabaskarR-06/guessthename

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

GuessTheSuit Smart Contract

A very simple Solidity smart contract for learning and testing purposes. The contract lets a user guess which playing card suit is marked as the “best” one.

There are no constructor parameters, no ETH involved, and no storage changes — just a pure on-chain logic check.


Contract Overview

  • Written in Solidity ^0.8.0
  • Deployed with no inputs
  • Uses an enum to represent card suits
  • Returns true or false when a guess is made

Suits Mapping

The contract uses the following numeric mapping:

Number Suit
0 Clubs
1 Diamonds
2 Hearts
3 Spades

The “best” (winning) suit is Spades (3).

Suit private constant BEST_SUIT = Suit.Spades;

How It Works

  1. A user calls the guessSuit function.

  2. The user passes a number between 0 and 3.

  3. The function checks if the guess matches the fixed suit.

  4. The function returns:

    • true → correct guess
    • false → incorrect guess

If the number is outside the valid range, the transaction reverts.


Function Reference

guessSuit

function guessSuit(uint8 suitIndex) external pure returns (bool)

Parameters

  • suitIndex — A number from 0 to 3

Returns

  • true if the guessed suit matches the best suit
  • false otherwise

Deployment

You can deploy this contract using:

  • Remix IDE
  • Hardhat
  • Foundry

There are no constructor arguments to provide during deployment.


Example (Remix)

  1. Open Remix
  2. Create GuessTheSuit.sol
  3. Paste the contract code
  4. Compile with version 0.8.x
  5. Deploy
  6. Call guessSuit(3) → returns true

Notes & Limitations

  • The best suit is hard-coded
  • No state is saved
  • No players or rewards are tracked
  • This contract is intended for learning and demos only

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors