hackquest logo

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 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.


🪙 Event

InteractionLogged(address indexed user, uint256 timestamp, uint256 id)

Emitted whenever a new interaction is logged.


🧰 How to Use

  1. Open the contract on Etherscan (or your testnet equivalent).

  2. Connect your wallet.

  3. Under the Write Contract tab, click interact() → Confirm the transaction.

  4. Under the Read Contract tab, check your logs with getMyInteractions() or getAllInteractions().


📦 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%

Tech Stack

Web3
Solidity
Ethers
Team Leader
DDevansh Sharma
Sector
AI