A simple payment splitter validator written in Aiken and its off-chain counterpart. The Aiken code is located in the onchain directory, while the off-chain code is in the offchain directory.
The validator checks two simple rules:
- The list of (unique) payment credentials must match the provided list of "known payees." This list can be provided as a parameter to the validator.
- The sum of the outputs (by payment credentials) must be equally split. (Excluding change outputs)
cd onchain
aiken test
aiken build
- Node >= 16
- Yarn
cd offchain
yarn install
node use-payment-splitter.js prepare 5
Copy the address from the output of the previous command and send some test Ada on the preprod network to this address. If you don't have test Ada at all, you can get some from the Cardano Testnets Faucet.
Anyone can lock funds in the payment splitter by sending an amount to the contract address.
node use-payment-splitter.js lock 10000000
Example transaction: https://preprod.cexplorer.io/tx/0008dd3ead94b0ca922ad45162762d73b5200efc5565a24532f1517fdf060dee
This command will generate a transaction that calculates the total available Lovelace value within the contract UTXOs and distributes the funds among the payees.
node use-payment-splitter.js unlock
Example transaction: https://preprod.cexplorer.io/tx/53be51e0f1268d41caae2944a760387fd762e76058aceddee73ca507d9e9a9c7