Created
March 10, 2026 12:42
-
-
Save renso3x/1f2aa8b9c31e021bf24c15a1ee2102cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.31; | |
| contract SimpleLogger { | |
| /** | |
| Activity 1 | |
| Instructions: | |
| Declare an event ActionPerformed(address user, string action). | |
| Create a function logAction(string memory _action) that: | |
| Emits the event with msg.sender and the _action text. | |
| Deploy and test by sending several actions like "Login", "Logout", "UpdateProfile". | |
| Observe the emitted event in Remix’s “Logs” tab. | |
| */ | |
| event ActionPerformed(address user, string action); | |
| function logAction(string memory _action) external { | |
| emit ActionPerformed(msg.sender, _action); | |
| } | |
| /** | |
| ACTIVITY 2 – Voting Tracker | |
| Instructions: | |
| Declare an event VoteCasted(address indexed voter, uint proposalId, bool choice). | |
| Create a function vote(uint _proposalId, bool _choice) that emits this event. | |
| Test by voting from multiple accounts. | |
| View logs to confirm who voted and for which proposal. | |
| */ | |
| event VoteCasted(address indexed voter, uint proposalId, bool choice); | |
| function vote(uint _proposalId, bool _choice) external { | |
| // Test by voting from multiple accounts. | |
| emit VoteCasted(msg.sender, _proposalId, _choice); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment