Interaction Logger
This smart contract records every time a user interacts with it. Each interaction stores:
Description
š§ Interaction Logger Smart Contract
A simple Solidity smart contract that logs user interactions with timestamps, deployed on the blockchain at:
Contract Address:
0x4aaaa15d127F9C8b810894aC24FBB1bfCa5dC386
š Description
This smart contract records every time a user interacts with it.
Each interaction stores:
The address of the caller (
msg.sender)The timestamp of the interaction
An auto-incremented ID
It also emits an event InteractionLogged every time someone calls the interact() function.
āļø Key Features
ā No constructor
ā No input fields in any function
ā Emits event logs for every interaction
ā Provides read-only functions to view logs
ā Fully self-contained ā no imports required
š§© Contract Functions
interact()
Logs a new interaction from the caller.
Inputs: None
Outputs: None
Action: Stores
{user, timestamp, id}and emits an event.
totalInteractions() ā uint256
Returns the total number of interactions recorded.
getLastInteraction() ā (address, uint256, uint256)
Returns the details of the most recent interaction:
user: Address of the usertimestamp: Time of interaction (UNIX)id: Interaction ID
getMyInteractions() ā (uint256[] ids, uint256[] timestamps)
Returns only the callerās interaction IDs and timestamps.
getAllInteractions() ā (address[] users, uint256[] timestamps, uint256[] ids)
Returns all interactions stored in the contract.
ā ļø For large datasets, this function should be used off-chain due to gas cost.
šŖ Event
InteractionLogged(address indexed user, uint256 timestamp, uint256 id)
Emitted whenever a new interaction is logged.
š§° How to Use
Open the contract on Etherscan (or your testnet equivalent).
Connect your wallet.
Under the Write Contract tab, click
interact()ā Confirm the transaction.Under the Read Contract tab, check your logs with
getMyInteractions()orgetAllInteractions().
š¦ Deployment Details
Language: Solidity
Version: ^0.8.0
License: MIT
Address:
0x4aaaa15d127F9C8b810894aC24FBB1bfCa5dC386
š§āš» Author
Developed for demonstration and learning purposes.
Use it to understand Solidity state storage, events, and timestamp-based logging.
ā ļø Disclaimer
This contract is for educational purposes only.
Do not store sensitive data or deploy it to mainnet without proper auditing.
Progress During Hackathon
50%