Skip to content
Verified contractExactMIT

OmniDisperse

Address0xa2a7ff3e11bc2d1709eaa1f77e6fda6e64d9ba23
Balance

0 ETH

 

Transactions

19

 

Compiler

solc 0.8.20

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.20+commit.a1b79de6
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
22,479,459
Creation transaction
0xf6e4d2dd9e…db94237b6e

contracts/OmniDisperse.sol

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

/**
 * @title OmniDisperse
 * @dev A simple contract for distributing tokens to multiple addresses in a single transaction.
 * This is an upgraded version of the original Disperse.app contract, designed to work across
 * multiple EVM chains including Ethereum, BNB Chain, and Bera Chain.
 */
contract OmniDisperse {
    /**
     * @dev Distributes the exact same amount of Ether to multiple recipients
     * @param recipients Array of recipient addresses
     * @param amount Amount of Ether to send to each recipient
     */
    function disperseEther(address[] calldata recipients, uint256 amount) external payable {
        uint256 total = amount * recipients.length;
        require(msg.value >= total, "OmniDisperse: Insufficient Ether sent");
        
        for (uint256 i = 0; i < recipients.length; i++) {
            (bool success, ) = recipients[i].call{value: amount}("");
            require(success, "OmniDisperse: Transfer failed");
        }
        
        // Return any excess Ether
        uint256 remaining = msg.value - total;
        if (remaining > 0) {
            (bool success, ) = msg.sender.call{value: remaining}("");
            require(success, "OmniDisperse: Refund failed");
        }
    }
    
    /**
     * @dev Distributes different amounts of Ether to multiple recipients
     * @param recipients Array of recipient addresses
     * @param amounts Array of amounts to send to each recipient
     */
    function disperseEtherExact(address[] calldata recipients, uint256[] calldata amounts) external payable {
        require(recipients.length == amounts.length, "OmniDisperse: Arrays length mismatch");
        
        uint256 total = 0;
        for (uint256 i = 0; i < amounts.length; i++) {
            total += amounts[i];
        }
        require(msg.value >= total, "OmniDisperse: Insufficient Ether sent");
        
        for (uint256 i = 0; i < recipients.length; i++) {
            (bool success, ) = recipients[i].call{value: amounts[i]}("");
            require(success, "OmniDisperse: Transfer failed");
        }
        
        // Return any excess Ether
        uint256 remaining = msg.value - total;
        if (remaining > 0) {
            (bool success, ) = msg.sender.call{value: remaining}("");
            require(success, "OmniDisperse: Refund failed");
        }
    }
    
    /**
     * @dev Distributes the exact same amount of an ERC20 token to multiple recipients
     * @param token Address of the ERC20 token
     * @param recipients Array of recipient addresses
     * @param amount Amount of tokens to send to each recipient
     */
    function disperseToken(address token, address[] calldata recipients, uint256 amount) external {
        uint256 total = amount * recipients.length;
        
        // Transfer tokens from sender to this contract
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(0x23b872dd, msg.sender, address(this), total) // transferFrom
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), "OmniDisperse: TransferFrom failed");
        
        // Transfer tokens from this contract to each recipient
        for (uint256 i = 0; i < recipients.length; i++) {
            (success, data) = token.call(
                abi.encodeWithSelector(0xa9059cbb, recipients[i], amount) // transfer
            );
            require(success && (data.length == 0 || abi.decode(data, (bool))), "OmniDisperse: Transfer failed");
        }
    }
    
    /**
     * @dev Distributes different amounts of an ERC20 token to multiple recipients
     * @param token Address of the ERC20 token
     * @param recipients Array of recipient addresses
     * @param amounts Array of amounts to send to each recipient
     */
    function disperseTokenExact(address token, address[] calldata recipients, uint256[] calldata amounts) external {
        require(recipients.length == amounts.length, "OmniDisperse: Arrays length mismatch");
        
        uint256 total = 0;
        for (uint256 i = 0; i < amounts.length; i++) {
            total += amounts[i];
        }
        
        // Transfer tokens from sender to this contract
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(0x23b872dd, msg.sender, address(this), total) // transferFrom
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), "OmniDisperse: TransferFrom failed");
        
        // Transfer tokens from this contract to each recipient
        for (uint256 i = 0; i < recipients.length; i++) {
            (success, data) = token.call(
                abi.encodeWithSelector(0xa9059cbb, recipients[i], amounts[i]) // transfer
            );
            require(success && (data.length == 0 || abi.decode(data, (bool))), "OmniDisperse: Transfer failed");
        }
    }
}
Compiler settingsShow
{
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.