Skip to content
DevVichyPublic

About

ERC-20 payment splitter in Solidity with fuzz tests (Foundry)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

split-pay

A small ERC-20 payment splitter in Solidity. Create a split once, then anyone can pay into it and every recipient is paid in the same transaction.

Useful for revenue sharing, group payments and team payouts, and it is the same idea as the payout routing in GemJar's prize pool.

How it works

  1. createSplit(recipients, shares) registers a split. Shares are in basis points and must sum to 10,000. Splits are immutable.
  2. pay(id, token, amount) pulls amount of token from the caller and pays each recipient their share in the same transaction.
  3. Rounding dust goes to the last recipient, so the contract never holds a balance.

Design notes

  • Fee-on-transfer tokens: the contract distributes the balance it actually received, not the nominal amount.
  • Non-standard ERC-20s: transfers use low-level calls and accept tokens that return no value.
  • No admin, no upgrade path, no stored funds. The contract is a stateless router once a payment completes.
  • Recipients are limited to 50 per split to keep gas bounded. Duplicates and zero addresses are rejected.

Usage

git clone --recurse-submodules https://github.com/DevVichy/split-pay.git
cd split-pay
forge build
forge test

Tests

  • 14 unit tests cover validation, event emission, exact splits, rounding dust, missing allowance and a fee-on-transfer token.
  • 3 fuzz tests (512 runs each) check that all funds are distributed, nothing stays in the contract, and the last recipient absorbs at most n - 1 wei of dust.

Status

Not audited and not deployed. Treat it as a reference implementation.

License

MIT

About

ERC-20 payment splitter in Solidity with fuzz tests (Foundry)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages