AutoDistributorETH

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "autodistributETH/AutoDistributorETH.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
 * @title AutoDistributorETH
 * @notice Automatically distributes any ETH received to predefined recipient wallets
 *         according to preset percentages.
 * @dev Percentages are expressed in basis points (10000 = 100%).
 */
contract AutoDistributorETH {
    address public immutable MASTER_WALLET = 0x99A3021538922a89d82A16233900940E25fB82d9;

    struct Receiver {
        address wallet;
        uint256 bps; // basis points (e.g., 5000 = 50%)
    }

    Receiver[] public receivers;

    event Distributed(uint256 totalAmount);
    event Received(address indexed sender, uint256 amount);

    constructor() {
        receivers.push(Receiver(0xCAB5Ea022e285e1d0e839ED02FAcCc6489eE0BB2, 5000)); // 50%
        receivers.push(Receiver(0xa0ceFa3E958101C43f8de6f4562AC61D82305aA5, 1500)); // 15%
        receivers.push(Receiver(0xEB97020acd5307438CD638892Be1D3516587Bbe3, 1250)); // 12.5%
        receivers.push(Receiver(0x4e5787dF300Af3A879c30003fF04345d63f15651, 1000)); // 10%
        receivers.push(Receiver(0x23CEC6907b83Ce0893538229A279548cc6C2068C, 500));  // 5%
        receivers.push(Receiver(0x867419B9a18de0640e6bb022e03280C3c5f21902, 300));  // 3%
        receivers.push(Receiver(0x9C8fDC36335dcc56BD0e07B3FDD8f9A21Def8087, 300));  // 3%
        receivers.push(Receiver(0xB161072cd7E0dad66464D23263126F2F2271eb55, 50));   // 0.5%
        receivers.push(Receiver(0x59df45c858dC7831B69f90692B950E0dbc092ddd, 50));   // 0.5%
        receivers.push(Receiver(0x96e95BA6896E2A50FaF44D3A0a05817e8079318A, 50));   // 0.5%
    }

    // Automatically trigger ETH distribution when ETH is received
    receive() external payable {
        emit Received(msg.sender, msg.value);
        distribute();
    }

    function distribute() internal {
        uint256 total = address(this).balance;
        require(total > 0, "No ETH to distribute");

        uint256 len = receivers.length;
        uint256 sentTotal = 0;

        for (uint256 i = 0; i < len; i++) {
            uint256 share = (total * receivers[i].bps) / 10000;
            sentTotal += share;
            (bool ok, ) = payable(receivers[i].wallet).call{value: share}("");
            require(ok, "ETH transfer failed");
        }

        // send any rounding dust to master wallet
        uint256 dust = address(this).balance;
        if (dust > 0) {
            (bool ok2, ) = payable(MASTER_WALLET).call{value: dust}("");
            require(ok2, "Dust transfer failed");
        }

        emit Distributed(total);
    }

    function getReceiversCount() external view returns (uint256) {
        return receivers.length;
    }
}
"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  }
}}

Tags:
Factory|addr:0xb77551f2d401410e59d196d2a2c9d3ac5f330877|verified:true|block:23743186|tx:0xe6f4752b5d3b6f8e7c77b5e0e0c5cae53aad5466b713068f1f39319fc3de63c0|first_check:1762509878

Submitted on: 2025-11-07 11:04:39

Comments

Log in to comment.

No comments yet.