If I have assets (can be just ADA for simplicity) locked in a contract, how can I release the funds to the previous owners most efficiently?

Some more context regarding the question. I created a pay endpoint (for the PAB), where different parties pay the same amount of ADA into a smart contract. Once a certain condition is met, the script can be consumed as an UTXO by another party (= getting paid some ADA). Until that condition is met, I want the parties that pay funds into the contract to essentially cancel the contract (= creating more appropriate UTXOs). In simple terms, the parties get their money back.

I have some code that solves this on a per-party basis, but I would like to get to the point where all parties get "reimbursed".

2 Answers 2


The best illustration of Plutus' capabilities in this case would be a Crowdfunding Contract.

Smart contracts are immutable, so the script must be triple-checked.

  • 1
    I want to create that moment. I thought tagging this questions with the appropriate tags would provide that context. I added more info. Oct 1, 2021 at 5:41
  • 1
    Matthias, I've updated my answer.
    – Andy Jazz
    Oct 1, 2021 at 6:30

I assume you have a redeemer that helps you understand when to run the "return founds" logic.

there are two options I can think you could implement, depending by how you expect the smart contract to be used

Use the Datum to keep track of the parties

you could store a PubKeyHash list ([PubKeyHash]) in the smart contract Datum and update the list for each new party.

if ever the "return founds" logic gets called you check that at least half the parties (or all of them if you prefer) have signed the transaction by checking the txInfoSignatories field

Important: due to the limited tx size you should use this approach if you expect not to have a lot of partecipants.

use tokens to identify parties

when someone decides to take part in the found you could mint some tokens to distribute proportionally to their contribution to the total found, and keep track of the total supply in the Datum

when the "return founds" logic is called you check for the input (or burned if you prefer) tokens to be at least half the total supply (or all of them if you prefer)

this approach should work also for a large number of participants since now the datum only stores an integer, no matter how many parties there are

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.