This smart contract records every time a user interacts with it. Each interaction stores:
A simple Solidity smart contract that logs user interactions with timestamps, deployed on the blockchain at:
Contract Address:
0x4aaaa15d127F9C8b810894aC24FBB1bfCa5dC386
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.
✅ 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
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 user
timestamp
: 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.
InteractionLogged(address indexed user, uint256 timestamp, uint256 id)
Emitted whenever a new interaction is logged.
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()
or getAllInteractions()
.
Language: Solidity
Version: ^0.8.0
License: MIT
Address: 0x4aaaa15d127F9C8b810894aC24FBB1bfCa5dC386
Developed for demonstration and learning purposes.
Use it to understand Solidity state storage, events, and timestamp-based logging.
This contract is for educational purposes only.
Do not store sensitive data or deploy it to mainnet without proper auditing.
50%