Michael Jordan

Description:

Smart contract deployed on Ethereum.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

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

/**
 *  THE GOAT
 *  -----------------------------------------------------------
 *  A playful, on-chain voting contract that stores Michael Jordan
 *  vs. LeBron James career statistics and lets anyone vote
 *  publicly on who is the real GOAT.
 */
contract THEGOAT {
    enum Side { None, Jordan, LeBron }

    struct PerGameLine {
        uint16 games;
        uint16 ppg10;
        uint16 rpg10;
        uint16 apg10;
        uint16 spg10;
        uint16 bpg10;
        uint16 fgPct1000;
        uint16 threePct1000;
        uint16 ftPct1000;
        uint16 efgPct1000;
        int16 bpm10;
        int16 vorp10;
    }

    struct Per36Line { uint16 pts10; }
    struct Per100Line { uint16 pts10; }

    struct AdvancedLine {
        int16 per10;
        uint16 tsPct1000;
        int16 ws48_1000;
    }

    struct Awards {
        bool hallOfFame;
        uint8 championships;
        uint8 allNBA1st;
        uint8 allNBA;
        uint8 allDef;
        uint8 mvp;
        bool dpoy;
        uint8 finalsMVP;
        uint8 allStar;
    }

    struct PlayerPack {
        string name;
        PerGameLine regular;
        Per36Line per36;
        Per100Line per100;
        AdvancedLine advanced;
        uint32 totalPoints;
        uint16 playoffsPPG10;
        int16 playoffsPER10;
        uint16 playoffsPer36Pts10;
        uint16 playoffsPer100Pts10;
        Awards awards;
    }

    PlayerPack private _mj;
    PlayerPack private _lbj;

    address public immutable owner;
    uint64 public votingCloses;
    mapping(address => Side) public voteOf;
    uint256 public jordanVotes;
    uint256 public lebronVotes;

    event Voted(address indexed voter, Side side, string message);
    event VotingClosed(uint64 at);

    modifier onlyOwner() {
        require(msg.sender == owner, "not owner");
        _;
    }

    modifier votingOpen() {
        if (votingCloses != 0) {
            require(block.timestamp < votingCloses, "voting closed");
        }
        _;
    }

    constructor(uint64 _votingClosesTs) {
        owner = msg.sender;
        votingCloses = _votingClosesTs;

        _mj.name = "Michael Jordan";
        _mj.regular = PerGameLine({
            games: 1072, ppg10: 301, rpg10: 62, apg10: 53,
            spg10: 23, bpg10: 8, fgPct1000: 497, threePct1000: 327,
            ftPct1000: 835, efgPct1000: 509, bpm10: 92, vorp10: 1161
        });
        _mj.per36 = Per36Line({ pts10: 283 });
        _mj.per100 = Per100Line({ pts10: 404 });
        _mj.advanced = AdvancedLine({ per10: 279, tsPct1000: 569, ws48_1000: 250 });
        _mj.totalPoints = 32292;
        _mj.playoffsPPG10 = 334;
        _mj.playoffsPER10 = 286;
        _mj.playoffsPer36Pts10 = 288;
        _mj.playoffsPer100Pts10 = 433;
        _mj.awards = Awards({
            hallOfFame: true, championships: 6, allNBA1st: 10, allNBA: 11,
            allDef: 9, mvp: 5, dpoy: true, finalsMVP: 6, allStar: 14
        });

        _lbj.name = "LeBron James";
        _lbj.regular = PerGameLine({
            games: 1562, ppg10: 270, rpg10: 75, apg10: 74,
            spg10: 15, bpg10: 7, fgPct1000: 506, threePct1000: 349,
            ftPct1000: 737, efgPct1000: 548, bpm10: 85, vorp10: 1566
        });
        _lbj.per36 = Per36Line({ pts10: 257 });
        _lbj.per100 = Per100Line({ pts10: 366 });
        _lbj.advanced = AdvancedLine({ per10: 269, tsPct1000: 590, ws48_1000: 221 });
        _lbj.totalPoints = 42184;
        _lbj.playoffsPPG10 = 284;
        _lbj.playoffsPER10 = 279;
        _lbj.playoffsPer36Pts10 = 247;
        _lbj.playoffsPer100Pts10 = 367;
        _lbj.awards = Awards({
            hallOfFame: false, championships: 4, allNBA1st: 13, allNBA: 21,
            allDef: 6, mvp: 4, dpoy: false, finalsMVP: 4, allStar: 21
        });
    }

    // Voting
    function vote(Side side, string calldata message) external votingOpen {
        require(side == Side.Jordan || side == Side.LeBron, "invalid side");
        Side prev = voteOf[msg.sender];

        if (prev == Side.Jordan && side != Side.Jordan) jordanVotes -= 1;
        if (prev == Side.LeBron && side != Side.LeBron) lebronVotes -= 1;

        if (prev == Side.None) {
            if (side == Side.Jordan) jordanVotes++; else lebronVotes++;
        } else if (prev != side) {
            if (side == Side.Jordan) jordanVotes++; else lebronVotes++;
        }

        voteOf[msg.sender] = side;
        emit Voted(msg.sender, side, message);
    }

    function getTally() external view returns (uint256 mj, uint256 lbj) {
        return (jordanVotes, lebronVotes);
    }

    function closeVotingNow() external onlyOwner {
        votingCloses = uint64(block.timestamp);
        emit VotingClosed(votingCloses);
    }

    // Read-only summary
    function summary() external view returns (
        uint16 mjGames, uint16 lbjGames,
        uint16 mjPPG10, uint16 lbjPPG10,
        uint16 mjPer36Pts10, uint16 lbjPer36Pts10,
        uint16 mjPer100Pts10, uint16 lbjPer100Pts10,
        uint32 mjTotalPts, uint32 lbjTotalPts
    ) {
        return (
            _mj.regular.games, _lbj.regular.games,
            _mj.regular.ppg10, _lbj.regular.ppg10,
            _mj.per36.pts10, _lbj.per36.pts10,
            _mj.per100.pts10, _lbj.per100.pts10,
            _mj.totalPoints, _lbj.totalPoints
        );
    }

    receive() external payable { revert("no ETH"); }
    fallback() external payable { revert("no ETH"); }
}

Tags:
addr:0x0b66df1b19de159fc8789ac54cc736a5ae2fb334|verified:true|block:23671073|tx:0xc6ce4a578059ca7303d6d6e47c9ba7de0300b3f42199fd804b3aa2ce23d39fe1|first_check:1761641846

Submitted on: 2025-10-28 09:57:28

Comments

Log in to comment.

No comments yet.