Source Code
Overview
CELO Balance
CELO Value
$0.00Multichain Info
Latest 25 from a total of 4,090 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Submit Answer | 42706511 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706508 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706505 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706502 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706498 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706495 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706492 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706490 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706486 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706482 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706393 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706389 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706385 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706382 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706379 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42706376 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706372 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706368 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706365 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42706362 | 178 days ago | IN | 0 CELO | 0.00077355 | ||||
| Submit Answer | 42703429 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42703426 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42703423 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42703420 | 178 days ago | IN | 0 CELO | 0.00077385 | ||||
| Submit Answer | 42703417 | 178 days ago | IN | 0 CELO | 0.00077385 |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MathChallenge2
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 MathChallenge2 {
/*//////////////////////////////////////////////////////////////
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 + 4^1 - 2^3?";
/// @notice The correct numerical answer to the mathematical problem
/// @dev Immutable to prevent tampering after deployment, ensuring problem integrity
uint256 public immutable correctAnswer = 252; // 256 + 4 - 8 = 252
/// @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
}{
"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,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
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"}]Contract Creation Code
60a060405234610155576100135f54610159565b601f811161010e575b507f5768617420697320325e38202b20345e31202d20325e333f00000000000000305f5560fc6080526001805461005290610159565b601f81116100e2575b671cdd589d1c9858dd60c21b60028360918155805f527f706f6e656e742073657061726174656c792c207468656e2061646420616e642060205f20917f427265616b20697420646f776e3a2063616c63756c617465206561636820657883558201550155600280556040516105839081610192823960805181818161021501526102a30152f35b815f526003601f60205f20920160051c820191015b818110610104575061005b565b5f815582016100f7565b5f8052601f0160051c7f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563908101905b81811061014a575061001c565b5f815560010161013d565b5f80fd5b90600182811c92168015610187575b602083101461017357565b634e487b7160e01b5f52602260045260245ffd5b91607f169161016856fe6080604081815260049182361015610015575f80fd5b5f3560e01c90816319cae462146104ec5750806345324688146104145780635e36bdc6146103d6578063672657be1461039b5780637c3572c2146102385780639cc4959e146101fe578063aef765011461019c5763fbf552db14610077575f80fd5b34610198575f366003190112610198578051905f60018054908160011c906001831692831561018e575b602093848410811461017b5783885290811561015f5750600114610109575b505050829003601f01601f191682019267ffffffffffffffff8411838510176100f657508291826100f2925282610506565b0390f35b604190634e487b7160e01b5f525260245ffd5b60015f908152929350837fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b83851061014b57505050508301015f80806100c0565b805488860183015293019284908201610135565b60ff1916878501525050151560051b84010190505f80806100c0565b602289634e487b7160e01b5f525260245ffd5b91607f16916100a1565b5f80fd5b5090346101985760203660031901126101985780356001600160a01b03811690819003610198575f526003602052815f2054906020526100f260ff835f2054169260025490519384938460409194939260608201958252151560208201520152565b5034610198575f36600319011261019857602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b5034610198576020908160031936011261019857823591335f5283815260ff825f20541661035957335f5260038152815f2080545f198114610346579160039160017f8ed3dbd665946ecf5fcb334543220c585bf9e15c5045a36d9266ea9b80dc4c249697940190557f0000000000000000000000000000000000000000000000000000000000000000861492836102fc575b50335f52526102f7825f2054925192839233968460409194939260608201958252151560208201520152565b0390a2005b335f528152835f20600160ff19825416179055818152835f205484519081527fea3fc8aff0cd50c52295ce35f9f4e917f7d51d9426ce17cd2c6119cf7a4836f3823392a25f6102cb565b601186634e487b7160e01b5f525260245ffd5b8390606492519162461bcd60e51b8352820152601b60248201527f416c726561647920736f6c76656420746869732070726f626c656d00000000006044820152fd5b50903461019857602036600319011261019857356001600160a01b0381169190829003610198576020915f5260038252805f20549051908152f35b50346101985760203660031901126101985781356001600160a01b0381169290839003610198576020925f52825260ff815f20541690519015158152f35b5034610198575f366003190112610198578051905f805460018160011c90600183169283156104e2575b602093848410811461017b5783885290811561015f575060011461048e57505050829003601f01601f191682019267ffffffffffffffff8411838510176100f657508291826100f2925282610506565b5f808052929350837f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8385106104ce57505050508301015f80806100c0565b8054888601830152930192849082016104b8565b91607f169161043e565b34610198575f366003190112610198576020906002548152f35b602080825282518183018190529093925f5b82811061053957505060409293505f838284010152601f8019910116010190565b81810186015184820160400152850161051856fea2646970667358221220bcaa270776551fd879c9ad478e949955f183d3df2b371d3bd5c8b66ece5284e864736f6c63430008180033
Deployed Bytecode
0x6080604081815260049182361015610015575f80fd5b5f3560e01c90816319cae462146104ec5750806345324688146104145780635e36bdc6146103d6578063672657be1461039b5780637c3572c2146102385780639cc4959e146101fe578063aef765011461019c5763fbf552db14610077575f80fd5b34610198575f366003190112610198578051905f60018054908160011c906001831692831561018e575b602093848410811461017b5783885290811561015f5750600114610109575b505050829003601f01601f191682019267ffffffffffffffff8411838510176100f657508291826100f2925282610506565b0390f35b604190634e487b7160e01b5f525260245ffd5b60015f908152929350837fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b83851061014b57505050508301015f80806100c0565b805488860183015293019284908201610135565b60ff1916878501525050151560051b84010190505f80806100c0565b602289634e487b7160e01b5f525260245ffd5b91607f16916100a1565b5f80fd5b5090346101985760203660031901126101985780356001600160a01b03811690819003610198575f526003602052815f2054906020526100f260ff835f2054169260025490519384938460409194939260608201958252151560208201520152565b5034610198575f36600319011261019857602090517f00000000000000000000000000000000000000000000000000000000000000fc8152f35b5034610198576020908160031936011261019857823591335f5283815260ff825f20541661035957335f5260038152815f2080545f198114610346579160039160017f8ed3dbd665946ecf5fcb334543220c585bf9e15c5045a36d9266ea9b80dc4c249697940190557f00000000000000000000000000000000000000000000000000000000000000fc861492836102fc575b50335f52526102f7825f2054925192839233968460409194939260608201958252151560208201520152565b0390a2005b335f528152835f20600160ff19825416179055818152835f205484519081527fea3fc8aff0cd50c52295ce35f9f4e917f7d51d9426ce17cd2c6119cf7a4836f3823392a25f6102cb565b601186634e487b7160e01b5f525260245ffd5b8390606492519162461bcd60e51b8352820152601b60248201527f416c726561647920736f6c76656420746869732070726f626c656d00000000006044820152fd5b50903461019857602036600319011261019857356001600160a01b0381169190829003610198576020915f5260038252805f20549051908152f35b50346101985760203660031901126101985781356001600160a01b0381169290839003610198576020925f52825260ff815f20541690519015158152f35b5034610198575f366003190112610198578051905f805460018160011c90600183169283156104e2575b602093848410811461017b5783885290811561015f575060011461048e57505050829003601f01601f191682019267ffffffffffffffff8411838510176100f657508291826100f2925282610506565b5f808052929350837f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b8385106104ce57505050508301015f80806100c0565b8054888601830152930192849082016104b8565b91607f169161043e565b34610198575f366003190112610198576020906002548152f35b602080825282518183018190529093925f5b82811061053957505060409293505f838284010152601f8019910116010190565b81810186015184820160400152850161051856fea2646970667358221220bcaa270776551fd879c9ad478e949955f183d3df2b371d3bd5c8b66ece5284e864736f6c63430008180033
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.