Skip to content

Instantly share code, notes, and snippets.

@renso3x
Created March 10, 2026 12:42
Show Gist options
  • Select an option

  • Save renso3x/1f2aa8b9c31e021bf24c15a1ee2102cd to your computer and use it in GitHub Desktop.

Select an option

Save renso3x/1f2aa8b9c31e021bf24c15a1ee2102cd to your computer and use it in GitHub Desktop.
// 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