CELO Price: $0.10 (+3.77%)
Gas: 25 GWei

Contract

0x2D430022dDBf98D8fbd80BEAa227a3A722cea64F

Overview

CELO Balance

Celo Mainnet LogoCelo Mainnet LogoCelo Mainnet Logo0 CELO

CELO Value

$0.00

More Info

Private Name Tags

Multichain Info

Transaction Hash
Block
From
To
Submit Answer427565142025-08-08 12:47:52178 days ago1754657272IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
Submit Answer427565112025-08-08 12:47:49178 days ago1754657269IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427565082025-08-08 12:47:46178 days ago1754657266IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427565052025-08-08 12:47:43178 days ago1754657263IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427565022025-08-08 12:47:40178 days ago1754657260IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427564992025-08-08 12:47:37178 days ago1754657257IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427564962025-08-08 12:47:34178 days ago1754657254IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427564932025-08-08 12:47:31178 days ago1754657251IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427564892025-08-08 12:47:27178 days ago1754657247IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427564852025-08-08 12:47:23178 days ago1754657243IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427563902025-08-08 12:45:48178 days ago1754657148IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427563862025-08-08 12:45:44178 days ago1754657144IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427563822025-08-08 12:45:40178 days ago1754657140IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427563782025-08-08 12:45:36178 days ago1754657136IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427563752025-08-08 12:45:33178 days ago1754657133IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427563712025-08-08 12:45:29178 days ago1754657129IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427563682025-08-08 12:45:26178 days ago1754657126IN
0x2D430022...722cea64F
0 CELO0.0007735525.001
Submit Answer427563652025-08-08 12:45:23178 days ago1754657123IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
Submit Answer427563632025-08-08 12:45:21178 days ago1754657121IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
Submit Answer427563602025-08-08 12:45:18178 days ago1754657118IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
Submit Answer427562672025-08-08 12:43:45178 days ago1754657025IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
Submit Answer427562642025-08-08 12:43:42178 days ago1754657022IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
Submit Answer427562622025-08-08 12:43:40178 days ago1754657020IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
Submit Answer427562592025-08-08 12:43:37178 days ago1754657017IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
Submit Answer427562562025-08-08 12:43:34178 days ago1754657014IN
0x2D430022...722cea64F
0 CELO0.0007738525.001
View all transactions

Advanced mode:
Parent Transaction Hash Block From To
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MathChallenge4

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 200 runs

Other Settings:
cancun EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/**
 * @title MathChallenge
 * @notice A smart contract that presents mathematical problems for students to solve
 * @dev This contract allows deployment of individual math problems with tracking of student attempts and solutions
 * @custom:version 1.0.0
 */
contract MathChallenge4 {
    /*//////////////////////////////////////////////////////////////
                                STORAGE
    //////////////////////////////////////////////////////////////*/

    /// @notice The mathematical problem statement presented to students
    /// @dev Stored as a string to allow complex mathematical expressions and formatting
    string public problem = "What is 2^8 + 7^2 - 4^1?";

    /// @notice The correct numerical answer to the mathematical problem
    /// @dev Immutable to prevent tampering after deployment, ensuring problem integrity
    uint256 public immutable correctAnswer = 301; // 256 + 49 - 4 = 301

    /// @notice A hint to help students solve the problem
    /// @dev Can be updated by adding a setter function if needed for dynamic hints
    string public hint = "Break it down: calculate each exponent separately, then add and subtract";

    /// @notice Difficulty rating of the problem on a 1-5 scale
    /// @dev 1 = Very Easy, 2 = Easy, 3 = Medium, 4 = Hard, 5 = Very Hard
    uint256 public difficulty = 2;

    /*//////////////////////////////////////////////////////////////
                                MAPPINGS
    //////////////////////////////////////////////////////////////*/

    /// @notice Tracks the number of attempts each student has made
    /// @dev Maps student address to their attempt count for this specific problem
    mapping(address => uint256) public attempts;

    /// @notice Tracks whether each student has successfully solved the problem
    /// @dev Maps student address to boolean indicating if they've found the correct answer
    mapping(address => bool) public solved;

    /*//////////////////////////////////////////////////////////////
                                EVENTS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Emitted when a student submits an answer attempt
     * @dev Provides comprehensive logging for tracking student progress and analytics
     * @param student The address of the student making the attempt
     * @param answer The numerical answer submitted by the student
     * @param correct Whether the submitted answer was correct
     * @param attemptCount The total number of attempts this student has made
     */
    event Attempt(address indexed student, uint256 answer, bool correct, uint256 attemptCount);

    /**
     * @notice Emitted when a student successfully solves the problem
     * @dev Marks the completion milestone for analytics and potential reward distribution
     * @param student The address of the student who solved the problem
     * @param finalAttempts The total number of attempts it took to solve the problem
     */
    event ProblemSolved(address indexed student, uint256 finalAttempts);

    /*//////////////////////////////////////////////////////////////
                              CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Initializes a new math challenge with hardcoded problem details
     * @dev No parameters needed - all values are set directly in storage declarations
     */
    constructor() {
        // No initialization needed - all values are set in storage declarations above
    }

    /*//////////////////////////////////////////////////////////////
                            EXTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Allows students to submit their answer to the math problem
     * @dev Tracks attempts, validates answers, and emits appropriate events
     * @param answer The numerical answer the student believes is correct
     *
     * Requirements:
     * - Student must not have already solved this problem
     * - Function will increment attempt counter regardless of correctness
     *
     * Effects:
     * - Increments the student's attempt counter
     * - Sets solved status to true if answer is correct
     * - Emits Attempt event for all submissions
     * - Emits ProblemSolved event for correct answers
     *
     * @custom:emits Attempt
     * @custom:emits ProblemSolved (if answer is correct)
     */
    function submitAnswer(uint256 answer) external {
        // Prevent multiple solutions by the same student
        // This maintains the integrity of the "first solve" tracking
        require(!solved[msg.sender], "Already solved this problem");

        // Increment attempt counter before processing
        // This ensures the count is accurate even if the transaction reverts later
        attempts[msg.sender]++;

        // Check if the submitted answer matches the correct answer
        bool correct = (answer == correctAnswer);

        // Process correct answer
        if (correct) {
            // Mark as solved to prevent further attempts
            solved[msg.sender] = true;

            // Emit success event with final attempt count
            emit ProblemSolved(msg.sender, attempts[msg.sender]);
        }

        // Always emit attempt event for tracking and analytics
        // This provides a complete audit trail of all submission attempts
        emit Attempt(msg.sender, answer, correct, attempts[msg.sender]);
    }

    /**
     * @notice Retrieves comprehensive progress information for a specific student
     * @dev Provides a consolidated view of student progress without multiple calls
     * @param student The address of the student whose progress to query
     * @return attemptCount The total number of attempts made by this student
     * @return hasSolved Whether the student has successfully solved the problem
     * @return problemDifficulty The difficulty level of this problem (for context)
     *
     * Usage:
     * - Frontend applications can use this for displaying student dashboards
     * - Teachers can monitor individual student progress
     * - Analytics systems can aggregate data across multiple students
     */
    function getProgress(address student)
        external
        view
        returns (uint256 attemptCount, bool hasSolved, uint256 problemDifficulty)
    {
        return (
            attempts[student], // Number of attempts made
            solved[student], // Solution status
            difficulty // Problem difficulty for context
        );
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"student","type":"address"},{"indexed":false,"internalType":"uint256","name":"answer","type":"uint256"},{"indexed":false,"internalType":"bool","name":"correct","type":"bool"},{"indexed":false,"internalType":"uint256","name":"attemptCount","type":"uint256"}],"name":"Attempt","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"student","type":"address"},{"indexed":false,"internalType":"uint256","name":"finalAttempts","type":"uint256"}],"name":"ProblemSolved","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"attempts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"correctAnswer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"difficulty","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"student","type":"address"}],"name":"getProgress","outputs":[{"internalType":"uint256","name":"attemptCount","type":"uint256"},{"internalType":"bool","name":"hasSolved","type":"bool"},{"internalType":"uint256","name":"problemDifficulty","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hint","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"problem","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"solved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"answer","type":"uint256"}],"name":"submitAnswer","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a060405234610156576100135f5461015a565b601f811161010f575b507f5768617420697320325e38202b20375e32202d20345e313f00000000000000305f5561012d608052600180546100539061015a565b601f81116100e3575b671cdd589d1c9858dd60c21b60028360918155805f527f706f6e656e742073657061726174656c792c207468656e2061646420616e642060205f20917f427265616b20697420646f776e3a2063616c63756c617465206561636820657883558201550155600280556040516105839081610193823960805181818161021501526102a30152f35b815f526003601f60205f20920160051c820191015b818110610105575061005c565b5f815582016100f8565b5f8052601f0160051c7f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563908101905b81811061014b575061001c565b5f815560010161013e565b5f80fd5b90600182811c92168015610188575b602083101461017457565b634e487b7160e01b5f52602260045260245ffd5b91607f169161016956fe6080604081815260049182361015610015575f80fd5b5f3560e01c90816319cae462146104ec5750806345324688146104145780635e36bdc6146103d6578063672657be1461039b5780637c3572c2146102385780639cc4959e146101fe578063aef765011461019c5763fbf552db14610077575f80fd5b34610198575f366003190112610198578051905f60018054908160011c906001831692831561018e575b602093848410811461017b5783885290811561015f5750600114610109575b505050829003601f01601f191682019267ffffffffffffffff8411838510176100f657508291826100f2925282610506565b0390f35b604190634e487b7160e01b5f525260245ffd5b60015f908152929350837fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b83851061014b57505050508301015f80806100c0565b805488860183015293019284908201610135565b60ff1916878501525050151560051b84010190505f80806100c0565b602289634e487b7160e01b5f525260245ffd5b91607f16916100a1565b5f80fd5b5090346101985760203660031901126101985780356001600160a01b03811690819003610198575f526003602052815f2054906020526100f260ff835f2054169260025490519384938460409194939260608201958252151560208201520152565b5034610198575f36600319011261019857602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b5034610198576020908160031936011261019857823591335f5283815260ff825f20541661035957335f5260038152815f2080545f198114610346579160039160017f8ed3dbd665946ecf5fcb334543220c585bf9e15c5045a36d9266ea9b80dc4c249697940190557f0000000000000000000000000000000000000000000000000000000000000000861492836102fc575b50335f52526102f7825f2054925192839233968460409194939260608201958252151560208201520152565b0390a2005b335f528152835f20600160ff19825416179055818152835f205484519081527fea3fc8aff0cd50c52295ce35f9f4e917f7d51d9426ce17cd2c6119cf7a4836f3823392a25f6102cb565b601186634e487b7160e01b5f525260245ffd5b8390606492519162461bcd60e51b8352820152601b60248201527f416c726561647920736f6c76656420746869732070726f626c656d00000000006044820152fd5b50903461019857602036600319011261019857356001600160a01b0381169190829003610198576020915f5260038252805f20549051908152f35b50346101985760203660031901126101985781356001600160a01b0381169290839003610198576020925f52825260ff815f20541690519015158152f35b5034610198575f366003190112610198578051905f805460018160011c90600183169283156104e2575b602093848410811461017b5783885290811561015f575060011461048e57505050829003601f01601f191682019267ffffffffffffffff8411838510176100f657508291826100f2925282610506565b5f808052929350837f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8385106104ce57505050508301015f80806100c0565b8054888601830152930192849082016104b8565b91607f169161043e565b34610198575f366003190112610198576020906002548152f35b602080825282518183018190529093925f5b82811061053957505060409293505f838284010152601f8019910116010190565b81810186015184820160400152850161051856fea2646970667358221220c8052ce5d3901e2bd788037cede4c2b4da0a34ac77db163cce2952809d26d09564736f6c63430008180033

Deployed Bytecode

0x6080604081815260049182361015610015575f80fd5b5f3560e01c90816319cae462146104ec5750806345324688146104145780635e36bdc6146103d6578063672657be1461039b5780637c3572c2146102385780639cc4959e146101fe578063aef765011461019c5763fbf552db14610077575f80fd5b34610198575f366003190112610198578051905f60018054908160011c906001831692831561018e575b602093848410811461017b5783885290811561015f5750600114610109575b505050829003601f01601f191682019267ffffffffffffffff8411838510176100f657508291826100f2925282610506565b0390f35b604190634e487b7160e01b5f525260245ffd5b60015f908152929350837fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b83851061014b57505050508301015f80806100c0565b805488860183015293019284908201610135565b60ff1916878501525050151560051b84010190505f80806100c0565b602289634e487b7160e01b5f525260245ffd5b91607f16916100a1565b5f80fd5b5090346101985760203660031901126101985780356001600160a01b03811690819003610198575f526003602052815f2054906020526100f260ff835f2054169260025490519384938460409194939260608201958252151560208201520152565b5034610198575f36600319011261019857602090517f000000000000000000000000000000000000000000000000000000000000012d8152f35b5034610198576020908160031936011261019857823591335f5283815260ff825f20541661035957335f5260038152815f2080545f198114610346579160039160017f8ed3dbd665946ecf5fcb334543220c585bf9e15c5045a36d9266ea9b80dc4c249697940190557f000000000000000000000000000000000000000000000000000000000000012d861492836102fc575b50335f52526102f7825f2054925192839233968460409194939260608201958252151560208201520152565b0390a2005b335f528152835f20600160ff19825416179055818152835f205484519081527fea3fc8aff0cd50c52295ce35f9f4e917f7d51d9426ce17cd2c6119cf7a4836f3823392a25f6102cb565b601186634e487b7160e01b5f525260245ffd5b8390606492519162461bcd60e51b8352820152601b60248201527f416c726561647920736f6c76656420746869732070726f626c656d00000000006044820152fd5b50903461019857602036600319011261019857356001600160a01b0381169190829003610198576020915f5260038252805f20549051908152f35b50346101985760203660031901126101985781356001600160a01b0381169290839003610198576020925f52825260ff815f20541690519015158152f35b5034610198575f366003190112610198578051905f805460018160011c90600183169283156104e2575b602093848410811461017b5783885290811561015f575060011461048e57505050829003601f01601f191682019267ffffffffffffffff8411838510176100f657508291826100f2925282610506565b5f808052929350837f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8385106104ce57505050508301015f80806100c0565b8054888601830152930192849082016104b8565b91607f169161043e565b34610198575f366003190112610198576020906002548152f35b602080825282518183018190529093925f5b82811061053957505060409293505f838284010152601f8019910116010190565b81810186015184820160400152850161051856fea2646970667358221220c8052ce5d3901e2bd788037cede4c2b4da0a34ac77db163cce2952809d26d09564736f6c63430008180033

Block Transaction Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
0x2D430022dDBf98D8fbd80BEAa227a3A722cea64F
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.