Skip to content
Verified contractExactMIT

RentPaymentSplit

Address0xcdab3ccc66a0aa20614b3466d97ca4012180baab
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.31

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.31+commit.fd3a2265
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
24,098,031
Creation transaction
0x2ee4621835…e91aae93a9

RentPaymentSplit.sol

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

/**
 * @title RentPaymentSplit
 * @dev A contract that splits rent payments between multiple property owners
 *      based on their ownership percentages.
 */
contract RentPaymentSplit {
    
    event RentPaid(
        address indexed tenant,
        uint256 totalAmount,
        uint256 timestamp
    );
    
    event OwnerPaid(
        address indexed owner,
        uint256 amount,
        uint256 percentage
    );

    /**
     * @dev Pay rent split between owners
     * @param owners Array of owner wallet addresses
     * @param percentages Array of ownership percentages (in basis points, 5000 = 50%)
     */
    function payRent(
        address payable[] calldata owners,
        uint256[] calldata percentages
    ) external payable {
        require(msg.value > 0, "Must send ETH");
        require(owners.length > 0, "Must have at least one owner");
        require(owners.length == percentages.length, "Arrays must match");
        
        uint256 totalPercentage = 0;
        for (uint256 i = 0; i < percentages.length; i++) {
            require(owners[i] != address(0), "Invalid owner address");
            require(percentages[i] > 0, "Percentage must be > 0");
            totalPercentage += percentages[i];
        }
        require(totalPercentage == 10000, "Percentages must equal 100%");
        
        uint256 totalSent = 0;
        for (uint256 i = 0; i < owners.length; i++) {
            uint256 payment;
            
            if (i == owners.length - 1) {
                payment = msg.value - totalSent;
            } else {
                payment = (msg.value * percentages[i]) / 10000;
            }
            
            totalSent += payment;
            
            (bool success, ) = owners[i].call{value: payment}("");
            require(success, "Transfer failed");
            
            emit OwnerPaid(owners[i], payment, percentages[i]);
        }
        
        emit RentPaid(msg.sender, msg.value, block.timestamp);
    }
    
    /**
     * @dev Simple function to pay rent to exactly 2 owners
     */
    function payRentToTwoOwners(
        address payable owner1,
        address payable owner2,
        uint256 percentage1
    ) external payable {
        require(msg.value > 0, "Must send ETH");
        require(owner1 != address(0) && owner2 != address(0), "Invalid addresses");
        require(percentage1 > 0 && percentage1 < 10000, "Invalid percentage");
        
        uint256 percentage2 = 10000 - percentage1;
        
        uint256 payment1 = (msg.value * percentage1) / 10000;
        uint256 payment2 = msg.value - payment1;
        
        (bool success1, ) = owner1.call{value: payment1}("");
        require(success1, "Transfer to owner1 failed");
        
        (bool success2, ) = owner2.call{value: payment2}("");
        require(success2, "Transfer to owner2 failed");
        
        emit OwnerPaid(owner1, payment1, percentage1);
        emit OwnerPaid(owner2, payment2, percentage2);
        emit RentPaid(msg.sender, msg.value, block.timestamp);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.