hackquest logo

earncont copy

A minimalistic peer reward system built on Ethereum that allows users to tip peers and track earnings directly on-chain. Designed for simplicity — no imports, no constructors, and no input parameters

Sự miêu tả

# 🪙 EarnTrack — Peer Reward & Tipping Smart Contract

A minimalistic peer reward system built on Ethereum that allows users to tip peers and track earnings directly on-chain.

Designed for simplicity — no imports, no constructors, and no input parameters in any function.

---

## 📜 Contract Information

- Contract Name: EarnTrack

- Deployed Address: 0xA6CC8eae900CA48E5356cAad528BE62CA97ea33a](https://etherscan.io/address/0xA6CC8eae900CA48E5356cAad528BE62CA97ea33a)

- Network: Ethereum Mainnet (EVM-compatible)

- License: MIT

- Solidity Version: ^0.8.20

---

## 🚀 Overview

EarnTrack introduces a simple, on-chain tipping and earning system that requires no arguments in any function call.

Users can:

- Send ETH as tips.

- Earn and track their on-chain rewards.

- Withdraw their accumulated balance anytime.

- Auto-tip peers simply by sending ETH to the contract address.

---

## 🧩 Core Features

| Function | Description |

|-----------|--------------|

| 💸 tipPeer() | Send ETH to reward a pseudo-random peer. |

| 💰 withdrawEarnings() | Withdraw all your earned ETH. |

| 📊 viewMyEarnings() | View your current on-chain earnings. |

| 🤝 myLastPeer() | Check who you last tipped. |

| ⚡ receive() / fallback() | Sending ETH directly triggers automatic tipping. |

---

## 💻 Full Solidity Code

```solidity

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

contract EarnTrack {

mapping(address => uint256) private earnings;

mapping(address => address) private lastPeer;

uint256 private seed;

function tipPeer() public payable {

require(msg.value > 0, "Send ETH to tip");

address peer = address(uint160(uint256(keccak256(abi.encodePacked(

block.timestamp, msg.sender, seed

)))));

earnings[peer] += msg.value;

lastPeer[msg.sender] = peer;

seed = uint256(keccak256(abi.encodePacked(seed, block.number, msg.sender)));

}

function withdrawEarnings() external {

uint256 amount = earnings[msg.sender];

require(amount > 0, "No earnings to withdraw");

earnings[msg.sender] = 0;

(bool success, ) = msg.sender.call{value: amount}("");

require(success, "Withdraw failed");

}

function viewMyEarnings() external view returns (uint256) {

return earnings[msg.sender];

}

function myLastPeer() external view returns (address) {

return lastPeer[msg.sender];

}

receive() external payable { _autoTip(); }

fallback() external payable { _autoTip(); }

function _autoTip() internal {

if (msg.value > 0) {

(bool success, ) = address(this).call{value: msg.value}(

abi.encodeWithSignature("tipPeer()")

);

require(success, "Auto-tip failed");

}

}

}

Tiến độ hackathon

na

Công nghệ sử dụng

React
Next
Vue
Web3
Ethers
Node
Java
Solidity

Trạng thái huy động vốn

na

Trưởng nhóm
AAchint Mishra
Mã nguồn mở
Ngành
SocialFi