Thank you so much for the tutorial, it is tremendously helpful.
I do have some questions, however. I’m trying to create a SC for a credit-card like payment system in order to learn Plutus. I’m trying my best to make everything rely on off-chain code as little as possible.
In this system there would be 3 actors: the buyer, the merchant and the investor. Investors would pay to the SC with the intent of collecting more ADA than they put in later. Merchants will collect from the SC the amount they sold minus fees and buyers would be able to pay for their purchases some time (say, 30 days) after buying without interest, or later on with interest.
I have a few problems while trying to develop this system, however:
- When collecting, both collectFromScript and _collectFromScriptTxn_will not do: Transaction matching needs to find utxo with value smaller than the desired collection value for merchants (to collect many of them until reaching the expected value), and the value for investors will depend on other of the system’s attributes such as the default rate and the time since the investment happened. Also, the investors’ utxo may be used to pay a merchant.
- Even if utxo matching is possible with off-chain code (this seems to be done by collectFromScript at https://github.com/input-output-hk/plutus/blob/master/wallet-api/src/Wallet/API.hs), I’m afraid too many investors and/or merchants will try to compete for collection of the same utxo. It would be superb if there could be a way to allow the smart contract itself to decide which utxo to collect from (maybe your collectFromScriptMatching suggestion running on-chain?).
- Is it possible to collect some utxo partially?
Sorry for such a long post and so many questions, and sorry if this has been answered in the tutorial or if it’s somehow obvious; it takes some time to digest all this new stuff! Also, I believe many of these problems I have are common to investment funds in general, since fees and compensations are complex.
Thank you for the awesome work,