creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "/Users/karen/Sources/rg/eth-contracts/token-distributor/contracts/EtherDistribution.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\ncontract EtherDistribution {\n\n    /// Constant member variables\n    uint256 public constant PERCENTAGE100 = 100000;\n\n    /// Private variables\n    address[] private _distributionAddresses;\n    uint32[] private _distributionSharePercentages;\n\n    /// Events\n    event Received(address, uint);\n\n    /// Constructor\n    constructor(address[] memory distributionAddresses_,\n                uint32[] memory distributionSharePercentages_) {\n\n        require(distributionAddresses_.length == distributionSharePercentages_.length, \n            'Error: addresses size shall be equal to the share percentages size');\n    \n        uint256 sum = 0;\n        for (uint8 i = 0; i < distributionSharePercentages_.length; ++i) {\n            sum += distributionSharePercentages_[i];\n            require(PERCENTAGE100 >= distributionSharePercentages_[i],\n                                'Error: immediateReleasePercentage must be less than or equal to 100000');\n        }\n        require(PERCENTAGE100 == sum, 'Error: Sum of distribution share percentages must be 100000');\n\n        _distributionAddresses = distributionAddresses_;\n        _distributionSharePercentages = distributionSharePercentages_;\n    }\n\n    function getDistributionAddresses() view external returns(address[] memory) {\n        return _distributionAddresses;\n    }\n\n    function getDistributionSharePercentages() view external returns(uint32[] memory) {\n        return _distributionSharePercentages;\n    }\n\n    function getBalance() public view returns (uint) {\n        return address(this).balance;\n    }\n\n    receive() external payable {\n        emit Received(msg.sender, msg.value);\n\n        uint256 sum = 0;\n        uint256 value = 0;\n        bool sent;\n        bytes memory data;\n\n        for (uint8 i = 0; i < _distributionSharePercentages.length - 1; ++i) {\n            value = msg.value * _distributionSharePercentages[i] / PERCENTAGE100;\n            sum += value;\n\n            (sent, data) = _distributionAddresses[i].call{\n                value: value\n            }(\"\");\n            require(sent, \"Failed to send Ether\");\n        }\n\n        (sent, data) = _distributionAddresses[_distributionAddresses.length - 1].call{\n                value: msg.value - sum\n            }(\"\");\n        require(sent, \"Failed to send Ether\");\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "evmVersion": "byzantium",
      "libraries": {},
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    }
  }}