Skip to content
Verified contractPartialMIT

RevenueShare

Address0x3e95bd45e77bceeec15ba4322ec7ef88061b61c8
Balance

0 ETH

 

Transactions

127

 

Compiler

solc 0.8.0

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.0+commit.c7dfd78e
Language
solidity
Optimization
Yes, 1 runs
EVM version
istanbul
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
21,623,668
Creation transaction
0xf278ddb81f…5c8e871ebb

RevenueShare.sol

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

contract RevenueShare {
    uint256 public claimInterval = 30 days; // Monthly claim interval
    uint256 public lastClaimInitializationTime; // Timestamp of the last claim initialization

    address private _owner;

    mapping(address => bool) public hasClaimed; // Track claimed status for the period
    mapping(address => uint256) public claimableAmountForPeriod; // Claimable ETH per wallet
    address[] public uploadedWallets; // List of uploaded wallets (for claim initialization)

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    event RevenueDistributed(address indexed wallet, uint256 amount);
    event ClaimInitialized(uint256 timestamp);
    event EligibleWalletUpdated(address wallet, uint256 balance);

    /// @notice Constructor sets the deployer as the owner
    constructor() {
        _owner = msg.sender;
        emit OwnershipTransferred(address(0), _owner);
    }

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

    /// @notice Transfers ownership to a new owner
    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "New owner cannot be the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }

    /// @notice Provide claimable amounts for eligible wallets
    /// @param wallets Array of wallet addresses
    /// @param balances Array of corresponding claimable balances
    function provideClaimableAmounts(address[] calldata wallets, uint256[] calldata balances) external onlyOwner {
        require(wallets.length == balances.length, "Mismatched input arrays");

        delete uploadedWallets; // Clear the previous list of wallets

        for (uint256 i = 0; i < wallets.length; i++) {
            claimableAmountForPeriod[wallets[i]] = balances[i];
            uploadedWallets.push(wallets[i]);
            emit EligibleWalletUpdated(wallets[i], balances[i]);
        }
    }

    /// @notice Initialize the claim period
    function initializeClaim() external onlyOwner {
        require(block.timestamp >= lastClaimInitializationTime + claimInterval, "Claim period not ended");

        // Reset claims for all uploaded wallets
        for (uint256 i = 0; i < uploadedWallets.length; i++) {
            hasClaimed[uploadedWallets[i]] = false;
        }

        lastClaimInitializationTime = block.timestamp;
        emit ClaimInitialized(block.timestamp);
    }

    /// @notice Claim the user's share of ETH
    function claimReward() public {
        require(block.timestamp < lastClaimInitializationTime + claimInterval, "Claim period expired");
        require(!hasClaimed[msg.sender], "Already claimed for this period");
        require(claimableAmountForPeriod[msg.sender] > 0, "No rewards available for this wallet");
        require(address(this).balance >= claimableAmountForPeriod[msg.sender], "Insufficient ETH in contract");

        uint256 share = claimableAmountForPeriod[msg.sender];
        hasClaimed[msg.sender] = true;

        // Reset claimable balance after claiming
        claimableAmountForPeriod[msg.sender] = 0;

        payable(msg.sender).transfer(share);

        emit RevenueDistributed(msg.sender, share);
    }

    /// @notice Fallback function to allow users to claim via sending 0 ETH
    receive() external payable {
        require(msg.value == 0, "Send 0 ETH to trigger claim");
        claimReward();
    }

    /// @notice View function to check claimable balance
    /// @param user The address to check for claimable balance
    /// @return The claimable ETH amount for the user
    function getClaimableBalance(address user) external view returns (uint256) {
        return claimableAmountForPeriod[user];
    }

    /// @notice Deposit ETH into the contract
    function depositETH() external payable onlyOwner {
        require(msg.value > 0, "Must send ETH to deposit");
    }

    /// @notice Withdraw ETH (only for the owner)
    function withdrawETH() external onlyOwner {
        payable(_owner).transfer(address(this).balance);
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 1,
    "enabled": true
  },
  "evmVersion": "istanbul",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.