hackquest logo

💸 Peer Tipping

A simple on-chain tipping mechanism that allows users to reward their peers with ETH directly on the blockchain.

Description

💸 Peer Tipping Smart Contract

A simple on-chain tipping mechanism that allows users to reward their peers with ETH directly on the blockchain.
This project is built for Flow Blockchain (Testnet) to demonstrate decentralized peer recognition and rewards.


🚀 Overview

The Peer Tipping Contract enables users to send ETH-based tips to peers in a decentralized and transparent manner.
Each peer accumulates tips over time and can withdraw their total balance anytime.

This implementation uses no imports, no constructors, and no input fields — maintaining a minimal and secure smart contract structure.


🧠 Key Features

  • Send Tips: Reward other users by sending ETH to the contract.

  • Withdraw Tips: Recipients can withdraw their accumulated tips anytime.

  • View Balance: Check how much tip balance you’ve received.

  • Owner Controls: The contract owner can perform an emergency withdrawal if needed.

  • Event Tracking: All activities are logged for transparency.


⚙️ Functions Overview

Function

Description

initialize()

Sets the contract owner (only callable once).

tipPeer()

Sends ETH as a tip to a randomly assigned peer.

withdrawTips()

Withdraws the sender’s accumulated tip balance.

getBalance()

Returns the tip balance for the caller.

emergencyWithdrawAll()

Allows owner to withdraw all ETH in emergencies.

receive()

Accepts direct ETH transfers.


📜 Example Flow

  1. Deploy Contract on Flow Testnet.

  2. Call initialize() once to set your wallet as the owner.

  3. Anyone can call tipPeer() and send ETH to a peer.

  4. Recipients call withdrawTips() to receive their rewards.

  5. Owner can use emergencyWithdrawAll() if needed.


🧩 Technical Details

  • Language: Solidity ^0.8.0

  • Libraries: None (pure Solidity)

  • Constructor: None (manual initialize() used)

  • Randomness: Simple pseudo-random peer generation (for demo)

  • Gas Efficient: Minimal storage and logic


🌐 Flow Testnet Deployment

Blockchain: Flow (Testnet)
Contract Address: 0xEBB5e4159aBb83cC6d6018b602b5F6bdDE8D40E2

You can interact with this contract using Flow’s testnet tools or Remix IDE configured for Flow EVM testnet.


🔒 Security Notes

  • This contract uses a pseudo-random function for demonstration.
    In production, a secure randomness source like Chainlink VRF should be used.

  • Always verify contract source and owner before interacting.

  • Keep private keys secure when calling initialize().


🧑‍💻 Example Usage (Remix)

  1. Copy-paste the contract into Remix.

  2. Select Solidity version 0.8.0.

  3. Deploy on Flow Testnet.

  4. Run:

    • initialize() to set yourself as owner.

    • tipPeer() and send ETH as msg.value.

    • withdrawTips() to withdraw received tips.


📬 Events

Event

Description

Initialized(address owner)

Logs contract initialization.

TipSent(address from, address to, uint256 amount)

Emitted when a tip is sent.

TipWithdrawn(address by, uint256 amount)

Emitted when a peer withdraws tips.

EmergencyWithdraw(address owner, uint256 amount)

Logs emergency withdrawals by the owner.


🧾 License

MIT License — Free to use, modify, and distribute.
Developed for educational and demonstration purposes on Flow Testnet.


🪙 Contract Address Summary

Flow Testnet Contract Address:
0xEBB5e4159aBb83cC6d6018b602b5F6bdDE8D40E2


🛠 Built For

Flow Blockchain — Testnet Environment
Demonstrating decentralized peer-to-peer tipping rewards.


Progress During Hackathon

80%

Tech Stack

Web3
Team Leader
Ssisui uchiha
Sector
DeFi