CELO Price: $0.10 (-5.80%)

Contract

0x02B7765b2F5A235732d2f1eDbf4100CfB0e875B8

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 Answer451700992025-09-05 11:14:17148 days ago1757070857IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.001
Submit Answer451700962025-09-05 11:14:14148 days ago1757070854IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451700932025-09-05 11:14:11148 days ago1757070851IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451700902025-09-05 11:14:08148 days ago1757070848IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451700882025-09-05 11:14:06148 days ago1757070846IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451700842025-09-05 11:14:02148 days ago1757070842IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451700812025-09-05 11:13:59148 days ago1757070839IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451700772025-09-05 11:13:55148 days ago1757070835IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451700732025-09-05 11:13:51148 days ago1757070831IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451700692025-09-05 11:13:47148 days ago1757070827IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.001
Submit Answer451699792025-09-05 11:12:17148 days ago1757070737IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.00104999
Submit Answer451699752025-09-05 11:12:13148 days ago1757070733IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.00104999
Submit Answer451699712025-09-05 11:12:09148 days ago1757070729IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.00104999
Submit Answer451699672025-09-05 11:12:05148 days ago1757070725IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.00104999
Submit Answer451699642025-09-05 11:12:02148 days ago1757070722IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.00104999
Submit Answer451699622025-09-05 11:12:00148 days ago1757070720IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.00104999
Submit Answer451699592025-09-05 11:11:57148 days ago1757070717IN
0x02B7765b...fB0e875B8
0 CELO0.0007739825.00104999
Submit Answer451699552025-09-05 11:11:53148 days ago1757070713IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.00104999
Submit Answer451699512025-09-05 11:11:49148 days ago1757070709IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.00104999
Submit Answer451699472025-09-05 11:11:45148 days ago1757070705IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.00104999
Submit Answer451698582025-09-05 11:10:16148 days ago1757070616IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.001
Submit Answer451698552025-09-05 11:10:13148 days ago1757070613IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.001
Submit Answer451698522025-09-05 11:10:10148 days ago1757070610IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.001
Submit Answer451698492025-09-05 11:10:07148 days ago1757070607IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.001
Submit Answer451698452025-09-05 11:10:03148 days ago1757070603IN
0x02B7765b...fB0e875B8
0 CELO0.0007742825.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:
MathChallenge1

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris 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 MathChallenge1 {
    /*//////////////////////////////////////////////////////////////
                                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 3^5 + 3^4 - 9^2 + 4 + 6?";

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

    /// @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
        );
    }

    /*//////////////////////////////////////////////////////////////
                            VIEW FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    // Note: All storage variables are already public, creating automatic getter functions:
    // - problem() returns the problem statement
    // - correctAnswer() returns the answer (consider making this private in production)
    // - hint() returns the hint
    // - difficulty() returns the difficulty level
    // - attempts(address) returns attempt count for a specific student
    // - solved(address) returns solved status for a specific student

    /*//////////////////////////////////////////////////////////////
                        POTENTIAL IMPROVEMENTS
    //////////////////////////////////////////////////////////////*/

    // Future enhancements could include:
    // 1. Access control for updating hints or problem statements
    // 2. Time-based challenges with deadlines
    // 3. Partial credit for close answers
    // 4. Integration with educational token rewards
    // 5. Batch operations for multiple problem deployments
    // 6. Student reputation system based on solving speed/attempts
}

Settings
{
  "remappings": [
    "forge-std/=lib/forge-std/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "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"}]

60a060405234610148576000610015815461014d565b601f811161011a575b50604181558080527f5768617420697320335e35202b20335e34202d20395e32202b2034202b20363f602082205560fd60805260019061005e825461014d565b601f81116100ee575b671cdd589d1c9858dd60c21b6002847f706f6e656e742073657061726174656c792c207468656e2061646420616e64206020866091845583815220917f427265616b20697420646f776e3a2063616c63756c6174652065616368206578835582015501556002805560405161058e90816101888239608051818181610214015261029e0152f35b8282526003601f60208420920160051c820191015b8181106101105750610067565b8281558301610103565b818052601f60208320910160051c810160018092015b81811061013e57505061001e565b8381558201610130565b600080fd5b90600182811c9216801561017d575b602083101461016757565b634e487b7160e01b600052602260045260246000fd5b91607f169161015c56fe60806040908082526004918236101561001757600080fd5b600091823560e01c90816319cae462146104f357508063453246881461041c5780635e36bdc6146103d9578063672657be1461039f5780637c3572c2146102375780639cc4959e146101fd578063aef765011461019f5763fbf552db1461007d57600080fd5b3461019b578160031936011261019b5780519082600180549081811c90808316928315610191575b602093848410811461017e57838852908115610162575060011461010d575b505050829003601f01601f191682019267ffffffffffffffff8411838510176100fa57508291826100f692528261050f565b0390f35b634e487b7160e01b815260418552602490fd5b8087529192508591837fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b83851061014e57505050508301013880806100c4565b805488860183015293019284908201610138565b60ff1916878501525050151560051b84010190503880806100c4565b634e487b7160e01b895260228a52602489fd5b91607f16916100a5565b5080fd5b509190346101fa5760203660031901126101fa5781356001600160a01b0381169081900361019b57815260036020908152838220549281529083902054600254935192835260ff161515908201526040810191909152606090f35b80fd5b503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b503461019b576020908160031936011261039b5783359133845284815260ff82852054166103595733845260038152818420805460001981146103465760010190557f8ed3dbd665946ecf5fcb334543220c585bf9e15c5045a36d9266ea9b80dc4c2491907f000000000000000000000000000000000000000000000000000000000000000084149060039087836102fc575b50338752526102f682862054925192839233968460409194939260608201958252151560208201520152565b0390a280f35b3388528152838720600160ff198254161790558181528387205484519081527fea3fc8aff0cd50c52295ce35f9f4e917f7d51d9426ce17cd2c6119cf7a4836f3823392a2876102ca565b634e487b7160e01b865260118752602486fd5b8490606492519162461bcd60e51b8352820152601b60248201527f416c726561647920736f6c76656420746869732070726f626c656d00000000006044820152fd5b8280fd5b50823461039b57602036600319011261039b57356001600160a01b0381169081900361039b57828291602094526003845220549051908152f35b50823461039b57602036600319011261039b5780356001600160a01b03811690819003610418578360ff92849260209652855220541690519015158152f35b8380fd5b503461019b578160031936011261019b57805190828354600181811c908083169283156104e9575b602093848410811461017e57838852908115610162575060011461049457505050829003601f01601f191682019267ffffffffffffffff8411838510176100fa57508291826100f692528261050f565b8680529192508591837f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8385106104d557505050508301013880806100c4565b8054888601830152930192849082016104bf565b91607f1691610444565b83903461019b578160031936011261019b576020906002548152f35b6020808252825181830181905290939260005b82811061054457505060409293506000838284010152601f8019910116010190565b81810186015184820160400152850161052256fea2646970667358221220cfaa6f679ef3418beb1f50b5943c8cb351ab1e756b617867425acd70bcb062a164736f6c63430008130033

Deployed Bytecode

0x60806040908082526004918236101561001757600080fd5b600091823560e01c90816319cae462146104f357508063453246881461041c5780635e36bdc6146103d9578063672657be1461039f5780637c3572c2146102375780639cc4959e146101fd578063aef765011461019f5763fbf552db1461007d57600080fd5b3461019b578160031936011261019b5780519082600180549081811c90808316928315610191575b602093848410811461017e57838852908115610162575060011461010d575b505050829003601f01601f191682019267ffffffffffffffff8411838510176100fa57508291826100f692528261050f565b0390f35b634e487b7160e01b815260418552602490fd5b8087529192508591837fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b83851061014e57505050508301013880806100c4565b805488860183015293019284908201610138565b60ff1916878501525050151560051b84010190503880806100c4565b634e487b7160e01b895260228a52602489fd5b91607f16916100a5565b5080fd5b509190346101fa5760203660031901126101fa5781356001600160a01b0381169081900361019b57815260036020908152838220549281529083902054600254935192835260ff161515908201526040810191909152606090f35b80fd5b503461019b578160031936011261019b57602090517f00000000000000000000000000000000000000000000000000000000000000fd8152f35b503461019b576020908160031936011261039b5783359133845284815260ff82852054166103595733845260038152818420805460001981146103465760010190557f8ed3dbd665946ecf5fcb334543220c585bf9e15c5045a36d9266ea9b80dc4c2491907f00000000000000000000000000000000000000000000000000000000000000fd84149060039087836102fc575b50338752526102f682862054925192839233968460409194939260608201958252151560208201520152565b0390a280f35b3388528152838720600160ff198254161790558181528387205484519081527fea3fc8aff0cd50c52295ce35f9f4e917f7d51d9426ce17cd2c6119cf7a4836f3823392a2876102ca565b634e487b7160e01b865260118752602486fd5b8490606492519162461bcd60e51b8352820152601b60248201527f416c726561647920736f6c76656420746869732070726f626c656d00000000006044820152fd5b8280fd5b50823461039b57602036600319011261039b57356001600160a01b0381169081900361039b57828291602094526003845220549051908152f35b50823461039b57602036600319011261039b5780356001600160a01b03811690819003610418578360ff92849260209652855220541690519015158152f35b8380fd5b503461019b578160031936011261019b57805190828354600181811c908083169283156104e9575b602093848410811461017e57838852908115610162575060011461049457505050829003601f01601f191682019267ffffffffffffffff8411838510176100fa57508291826100f692528261050f565b8680529192508591837f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8385106104d557505050508301013880806100c4565b8054888601830152930192849082016104bf565b91607f1691610444565b83903461019b578160031936011261019b576020906002548152f35b6020808252825181830181905290939260005b82811061054457505060409293506000838284010152601f8019910116010190565b81810186015184820160400152850161052256fea2646970667358221220cfaa6f679ef3418beb1f50b5943c8cb351ab1e756b617867425acd70bcb062a164736f6c63430008130033

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
0x02B7765b2F5A235732d2f1eDbf4100CfB0e875B8
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.