Scatter is a smart contract that enables efficient distribution of native currency (ETH), ERC20, and ERC1155 tokens to multiple recipients in a single transaction. Built with security in mind, it includes reentrancy protection, pausability, and owner-only emergency withdrawal functions.
- Multi-token Support: Distribute ETH, ERC20, and ERC1155 tokens
- Batch Transfers: Send tokens to multiple recipients in one transaction
- Security Features:
- Reentrancy protection
- Pausable functionality
- Owner-only emergency withdrawals
- Comprehensive input validation
- Gas Optimization: Special handling for single-recipient ERC1155 transfers
- Event Logging: Detailed events for all token distributions
scatterNativeCurrency(address[] recipients, uint256[] amounts)
: Distribute ETH to multiple addressesscatterERC20Token(address token, address[] recipients, uint256[] amounts)
: Distribute ERC20 tokensscatterERC1155Token(address token, address[] recipients, uint256[] amounts, uint256[] ids)
: Distribute ERC1155 tokens
pause()
: Pause all scatter operationsunpause()
: Resume scatter operationswithdrawStuckETH()
: Withdraw accidentally sent ETHwithdrawStuckERC20(address token)
: Withdraw accidentally sent ERC20 tokenswithdrawStuckERC1155(address token, uint256 id)
: Withdraw specific ERC1155 tokenswithdrawStuckERC1155Batch(address token, uint256[] ids)
: Batch withdraw ERC1155 tokens
scatter/
├── src/
│ └── Scatter.sol # Main contract implementation
├── test/
│ ├── Scatter.t.sol # Main test suite
│ └── mocks/ # Mock contracts for testing
│ ├── MockERC20.sol
│ ├── MockERC1155.sol
│ ├── RevertingMock.sol
│ └── GasConsumingMock.sol
├── script/
│ └── Scatter.s.sol # Deployment script
└── lib/ # Dependencies
- Clone the repository:
git clone https://github.com/0xJijimi/scatter.git
cd scatter
- Install dependencies:
forge install
- Copy the environment file and configure it:
cp .env.example .env
Run the test suite:
forge test
For detailed gas reports:
forge test --gas-report
- Create and activate a Python virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows use: .venv\Scripts\activate
- Install required dependencies:
pip install -r requirements.txt
- Install solc compiler:
pip install solc-select
solc-select install 0.8.28 # Install specific version
solc-select use 0.8.28 # Use this version
- Run Slither analysis:
slither .
-
Configure your deployment environment in
.env
-
Deploy using Foundry:
# Load environment variables
source .env
# Deploy the contract
forge script script/Scatter.s.sol:DeployScatter --rpc-url $MAINNET_RPC_URL --broadcast -vvvv --slow --ffi
# Verify the contract
forge verify-contract <DEPLOYED_CONTRACT_ADDRESS> <CONTRACT_NAME> --chain-id <CHAIN_ID> --watch
# Deploy AND verify in one command
forge script script/Scatter.s.sol:DeployScatter --rpc-url $MAINNET_RPC_URL --broadcast --verify -vvvv --slow --chain <CHAIN_ID> --ffi
Network | Contract Address | Explorer Link |
---|---|---|
Sonic Mainnet | 0xe907b1f554214129935820fdb8d7e771e1951d67 |
View |
Sonic Blaze Testnet | 0xf2fc843b45e999fc37e8f8a35f07af0844d388d8 |
View |
Monitor these events to track token distributions:
NativeCurrencyScattered(address indexed sender, address[] recipients, uint256[] amounts)
ERC20Scattered(address indexed sender, address indexed token, address[] recipients, uint256[] amounts)
ERC1155Scattered(address indexed sender, address indexed token, address[] recipients, uint256[] ids, uint256[] amounts)
- The contract implements reentrancy protection
- All functions perform thorough input validation
- Emergency withdrawal functions are owner-only
- The contract can be paused in case of emergencies
- Token approvals are required before scattering ERC20/ERC1155 tokens
MIT License