The contract implements a mechanism of payments to wallets, but instead of doing these payments directly, the lovelaces are blocked in a script, and then each wallet can collect them.
The contract has to store how many lovelaces correspond to each receiver. This
information is stored as a map from payment-pubkeyhashes to integers. So, the
main, and only, UTxO of the contract contains this map. The creation of this
main UTxO is perfomed by the run function that submits a transaction producing
the utxo containing the initial state where nobody has lovelaces to collect.
Main UTxO:
EscrowState: payments information
-
addPayment: given a payment-pubkeyhashpkhand an integerm, it submits a transaction paying to the scriptmlovelaces and modifying the state specifying that nowpkhhasmadditional lovelaces. -
collect: given a payment-pubkeyhashpkh, it submits a transaction spending the script-utxo and collecting the number of lovelaces specified in the state, corresponding to the pub keypkhsigning the transaction. If the transaction can be submitted, the state is modified deleting the map associationpkh ↦ mcorresponding to the signer.
The two main operations produce congestion: both of them spend the script main utxo, so only one user can interact with the contract per block.
Here you can find information about how to build this project and run the on-chain and off-chain tests.
Install the development environment following the official documentation.
Once you have all installed, you will start the environment with nix-shell
from the plutus repository folder and change into the project folder.
$> cabal build
$> cabal run test
You also can load the library or the tests with the repl with cabal repl or
cabal repl test.

