ETHSplitter is a
smart contract and a NextJs App built with
Scaffold ETH to split Ethereum
(ETH) or ERC20 tokens between multiple recipients. It provides functionality to
distribute ETH or ERC20 tokens according to specified amounts or equally among
recipients.
Disclaimer: This contract is a prototype and intended for research and development purposes only. Use it at your own discretion.
To get started with ETH Splitter, follow the steps below:
Clone this repo & install dependencies
git clone https://github.com/Avelous/Eth-Splitter.git
cd ETH-Splitter
yarn install
Run a local network in the first terminal:
yarn chain
This command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in hardhat.config.ts.
On a second terminal, deploy the test contract:
yarn deploy
This command deploys a test smart contract to the local network. The contract is located in packages/hardhat/contracts and can be modified to suit your needs. The yarn deploy command uses the deploy script located in packages/hardhat/deploy to deploy the contract to the network. You can also customize the deploy script.
On a third terminal, start your NextJS app:
yarn start
- Split ETH among multiple recipients based on specified amounts.
- Split ETH equally among multiple recipients.
- Split ERC20 tokens among multiple recipients based on specified amounts.
- Split ERC20 tokens equally among multiple recipients.
- Withdraw remaining ETH or ERC20 tokens to the contract owner.
- Deploy the ETHSplitter contract.
- Call the appropriate function to split ETH or ERC20 tokens among recipients.
- Recipients will receive their allocated amounts.
- The contract owner can withdraw any remaining ETH or ERC20 tokens.
function splitETH(address payable[] calldata recipients, uint256[] calldata amounts) external payable nonReentrant
This function splits the provided ETH among the given recipients according to the specified amounts.
recipients
: An array of payable addresses representing the recipients of the ETH.amounts
: An array of uint256 values specifying the amounts each recipient shall receive.
function splitEqualETH(address payable[] calldata recipients) external payable nonReentrant
This function splits the provided ETH equally among the given recipients.
recipients
: An array of payable addresses representing the recipients of the ETH.
function splitERC20(IERC20 token, address[] calldata recipients, uint256[] calldata amounts) external nonReentrant
This function splits the provided ERC20 tokens among the given recipients according to the specified amounts.
token
: The ERC20 token contract address.recipients
: An array of addresses representing the recipients of the ERC20 tokens.amounts
: An array of uint256 values specifying the amounts each recipient shall receive.
function splitEqualERC20(IERC20 token, address[] calldata recipients, uint256 totalAmount) external nonReentrant
This function splits the provided ERC20 tokens equally among the given recipients.
token
: The ERC20 token contract address.recipients
: An array of addresses representing the recipients of the ERC20 tokens.totalAmount
: The total amount of ERC20 tokens to be distributed equally.
function withdraw(IERC20 token) external onlyOwner
This function allows the contract owner to withdraw any remaining ETH or ERC20 tokens from the contract.
The contract emits the following events:
EthSplit
: Indicates the successful splitting of ETH among recipients.EthSplitEqual
: Indicates the successful equal splitting of ETH among recipients.Erc20Split
: Indicates the successful splitting of ERC20 tokens among recipients.Erc20SplitEqual
: Indicates the successful equal splitting of ERC20 tokens among recipients.
onlyOwner
: Ensures that only the contract owner can perform certain actions.
The frontend of the ETHSplitter contract is built using Next.js, providing a user interface to interact with the smart contract. It offers options to split ETH and ERC20 tokens equally or unequally among recipients. The frontend is bulit as a safe app to work with multisigs.
- Split ETH among recipients:
- Specify individual amounts for each recipient.
- Split ETH equally among recipients.
- Split ERC20 tokens among recipients:
- Specify individual amounts for each recipient.
- Split ERC20 tokens equally among recipients.
- Connect your Ethereum wallet to the application.
- Select the desired operation:
- Split ETH: Splitting Ether (ETH) among recipients.
- Split TOKEN: Splitting ERC20 tokens among recipients.
- Choose the split type:
- Unequal: Specify individual amounts for each recipient.
- Equal: Split the amount equally among recipients.
- Provide the required inputs:
- Recipients: Enter the addresses of the recipients, separated by commas.
- Amounts: Enter the corresponding amounts to be split among the recipients, separated by commas.
- Token Address (for ERC20): Enter the contract address of the ERC20 token (if applicable).
- Click the "Split" button to execute the transaction.
- Confirm the transaction using your connected wallet.
If you would like to contribute to the development of the ETHSplitter frontend, please follow these steps:
- Fork the repository and create a new branch for your feature or bug fix.
- Make the necessary changes and ensure the code follows the project's style guidelines.
- Write tests for any new functionality.
- Commit your changes and push them to your forked repository.
- Submit a pull request, describing your changes in detail and referencing any relevant issues.
Built with Scaffold ETH