Skip to content
Verified contractExactMIT

Engage

Address0x62d86af1006b1ebecd6f5520372fd1dde8e1da2d
Balance

0 ETH

 

Transactions

524

 

Compiler

solc 0.8.24

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.24+commit.e11b9ed9
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,690,688
Creation transaction
0xe50bdf529b…7b664c4d26

contracts/Engage.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @title  Engage — content-free engagement + loyalty for "cncptl prspctv"
/// @notice A standalone companion to Perspective. ANY wallet can:
///           - checkIn()          once per day (paid) → 10 + streak points
///           - react(dropId,kind) once per drop (gas-only) → a few points
///         Points are soulbound (never transferable) and drive the leaderboard.
///         It never touches the Perspective feed contract; it only records
///         reactions keyed by the drop id emitted there.
contract Engage {
    address public owner;

    uint256 public tapFee;   // wei required to checkIn (the "$0.10" buy-in)
    uint256 public reactFee; // wei required to react (0 = gas-only)

    uint256 public constant TAP_BASE = 10; // base points per daily check-in
    uint256 public constant REACT_POINTS = 2; // points per reaction
    uint8 public constant KINDS = 3; // 0 = heart, 1 = fire, 2 = gm

    uint256 public totalPoints;

    mapping(address => uint256) public points; // soulbound reputation
    mapping(address => uint256) public streak; // consecutive-day streak
    mapping(address => uint256) public lastTapDay; // unix day of last check-in

    mapping(uint256 => mapping(address => bool)) public reacted; // dropId => wallet => reacted?
    mapping(uint256 => mapping(uint8 => uint256)) public reactionCount; // dropId => kind => count

    address[] public members; // everyone who has ever earned points
    mapping(address => bool) private _isMember;

    event CheckedIn(address indexed wallet, uint256 day, uint256 streak, uint256 gained, uint256 points);
    event Reacted(uint256 indexed dropId, address indexed wallet, uint8 kind, uint256 points);
    event FeesChanged(uint256 tapFee, uint256 reactFee);
    event OwnerTransferred(address indexed from, address indexed to);

    error NotOwner();
    error InsufficientFee();
    error AlreadyTappedToday();
    error AlreadyReacted();
    error BadKind();
    error ZeroAddress();

    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner();
        _;
    }

    constructor(uint256 _tapFee, uint256 _reactFee) {
        owner = msg.sender;
        tapFee = _tapFee;
        reactFee = _reactFee;
        emit OwnerTransferred(address(0), msg.sender);
        emit FeesChanged(_tapFee, _reactFee);
    }

    function _touch(address w) private {
        if (!_isMember[w]) {
            _isMember[w] = true;
            members.push(w);
        }
    }

    /// @notice Daily loyalty tap-in. One per wallet per UTC day. Streak-weighted.
    function checkIn() external payable returns (uint256 gained) {
        if (msg.value < tapFee) revert InsufficientFee();
        uint256 today = block.timestamp / 1 days;
        uint256 last = lastTapDay[msg.sender];
        if (last == today) revert AlreadyTappedToday();

        streak[msg.sender] = (last != 0 && today == last + 1) ? streak[msg.sender] + 1 : 1;
        gained = TAP_BASE + streak[msg.sender];
        points[msg.sender] += gained;
        totalPoints += gained;
        lastTapDay[msg.sender] = today;
        _touch(msg.sender);

        emit CheckedIn(msg.sender, today, streak[msg.sender], gained, points[msg.sender]);
    }

    /// @notice React to a drop. One reaction per wallet per drop. Content-free.
    /// @param dropId the Perspective drop id
    /// @param kind   0 = heart, 1 = fire, 2 = gm
    function react(uint256 dropId, uint8 kind) external payable {
        if (msg.value < reactFee) revert InsufficientFee();
        if (kind >= KINDS) revert BadKind();
        if (reacted[dropId][msg.sender]) revert AlreadyReacted();

        reacted[dropId][msg.sender] = true;
        reactionCount[dropId][kind] += 1;
        points[msg.sender] += REACT_POINTS;
        totalPoints += REACT_POINTS;
        _touch(msg.sender);

        emit Reacted(dropId, msg.sender, kind, points[msg.sender]);
    }

    // ---------- views for the UI ----------

    function memberCount() external view returns (uint256) {
        return members.length;
    }

    /// @notice Reaction tallies for a drop: (hearts, fire, gm).
    function reactions(uint256 dropId) external view returns (uint256 hearts, uint256 fire, uint256 gm) {
        return (reactionCount[dropId][0], reactionCount[dropId][1], reactionCount[dropId][2]);
    }

    // ---------- owner ----------

    function setFees(uint256 _tapFee, uint256 _reactFee) external onlyOwner {
        tapFee = _tapFee;
        reactFee = _reactFee;
        emit FeesChanged(_tapFee, _reactFee);
    }

    /// @notice Sweep collected fees to `to`.
    function withdraw(address payable to) external onlyOwner {
        if (to == address(0)) revert ZeroAddress();
        (bool ok, ) = to.call{value: address(this).balance}("");
        require(ok, "withdraw failed");
    }

    function transferOwnership(address to) external onlyOwner {
        if (to == address(0)) revert ZeroAddress();
        emit OwnerTransferred(owner, to);
        owner = to;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.