Creator Collaboration Revenue Split

What it does:
Automatically splits incoming revenue among multiple creators and collaborators based on predefined percentages, enforced entirely on-chain.

Why it matters:
Eliminates trust issues between collaborators, removes manual accounting, ensures instant and transparent payouts, and enables global creator teams to monetize together without intermediaries.

How it works:

  • Creators define a collaboration with multiple payout addresses and fixed revenue shares

  • Revenue (ETH or tokens) is sent directly to the smart contract

  • Smart contract calculates each collaborator’s share based on predefined percentages

  • Funds are credited to individual on-chain balances automatically

  • Collaborators can withdraw their earnings at any time without relying on others

  • All revenue flows, balances, and payouts are transparent and auditable on-chain

  • Integrates seamlessly with content sales, subscriptions, NFTs, or licensing contracts

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

/**
 * @title CreatorCollaborationRevenueSplit
 * @author Nam
 * @notice Automatically splits revenue among multiple collaborators
 */
contract CreatorCollaborationRevenueSplit {

    uint256 public collaborationCount;

    struct Collaboration {
        address admin;
        address[] collaborators;
        mapping(address => uint256) shares; // percentage (out of 10000)
        mapping(address => uint256) balances;
        uint256 totalShares;
    }

    mapping(uint256 => Collaboration) public collaborations;

    // -------------------- EVENTS --------------------

    event CollaborationCreated(uint256 indexed collaborationId, address indexed admin);
    event RevenueReceived(uint256 indexed collaborationId, uint256 amount);
    event Withdrawal(uint256 indexed collaborationId, address indexed collaborator, uint256 amount);

    // -------------------- MODIFIERS --------------------

    modifier onlyAdmin(uint256 _collaborationId) {
        require(msg.sender == collaborations[_collaborationId].admin, "Not admin");
        _;
    }

    // -------------------- COLLABORATION MANAGEMENT --------------------

    function createCollaboration(
        address[] calldata _collaborators,
        uint256[] calldata _shares
    ) external returns (uint256) {
        require(_collaborators.length == _shares.length, "Length mismatch");
        require(_collaborators.length > 0, "No collaborators");

        uint256 total;
        for (uint256 i = 0; i < _shares.length; i++) {
            total += _shares[i];
        }
        require(total == 10000, "Shares must total 100%");

        collaborationCount += 1;
        Collaboration storage c = collaborations[collaborationCount];
        c.admin = msg.sender;
        c.collaborators = _collaborators;
        c.totalShares = total;

        for (uint256 i = 0; i  0, "No revenue");

        for (uint256 i = 0; i  0, "No balance");

        c.balances[msg.sender] = 0;
        payable(msg.sender).transfer(amount);

        emit Withdrawal(_collaborationId, msg.sender, amount);
    }

    function balanceOf(uint256 _collaborationId, address _user) external view returns (uint256) {
        return collaborations[_collaborationId].balances[_user];
    }
}