Payment Splitter

Split payouts equally among a list of specified payees

A payment splitter can be used for example to create a shared project donation address, ensuring that all payees receive the same amount

Sending lovelace to the contract works similarly to sending lovelace to any other address. The payout transaction can only be submitted by one of the payees, and the output addresses are restricted to the payees. The output sum must be equally divided to ensure the transaction is successful.

There are 2 actions (or endpoints) available to interact with this smart contract:

  • Send Lovelace to Payment Splitter
  • Trigger Payout

Install package

First you can to install the @meshsdk/contracts package:

Initialize the contract

To initialize the payment splitter, we need to initialize a provider, a MeshTxBuilder, and a MeshPaymentSplitterContract. Additionally, a list of payees is required to define the allowed payout addresses for the contract.

Both on-chain and off-chain codes are open-source and available on Mesh Github Repository.

Send Lovelace to Payment Splitter

sendLovelaceToSplitter() will lock Lovelace in the contract. The function accepts the following parameters:

  • lovelaceAmount (number) - the amount of Lovelace you want to send to the contract

The function returns a transaction hash.

Send Lovelace to Payment Splitter

Send Lovelace to the Payment Splitter contract to be distributed to the beneficiaries.

Connect wallet to run this demo

No wallets installed

Trigger Payout

triggerPayout() will split the locked amount equally among the list of payees. The function doesn't need any parameters.

The function returns a transaction hash if the payout has been done successfully.

Trigger Payout

After the amount has been locked in the contract, you can trigger the payout to the payees.

Connect wallet to run this demo

No wallets installed