hackquest logo

๐Ÿ’ธ Peer Tipping

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

๊ธฐ์ˆ  ์Šคํƒ

Web3

์„ค๋ช…

๐Ÿ’ธ 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.


ํ•ด์ปคํ†ค ์ง„ํ–‰ ์ƒํ™ฉ

80%
ํŒ€ ๋ฆฌ๋”
SSiddharth Sameer singh
ํ”„๋กœ์ ํŠธ ๋งํฌ
๋ถ€๋ฌธ
DeFi