0

In Plutonomicon github repo it says by the end of the page:

For example, you don't need to prevent an unexpected transaction from locking value away - that's the submitter's own problem - but you do need to stop them from inappropriately spending value.

As i understood, we dont need our on-chain part to fill in all variants of the off-chain code.

So, if we have, for example, some kind of dex Plutus script that sells tokens, assigned to script outputs: one output - one token. In that case we should avoid checking outputs' addresses of sell-transaction for correctness, even with probability of "dishonest" off-chain(for example, extra constraint "MustPayToPubKeyAddress")? Consider that fixed amount of minAda for each output is not set by script logic.

1 Answer 1

0

In your validator, you should check only for what is related to the script logic.

depending on your needs you may want your user only to perform that specific action in the transaction, so you can add additional checks that specify that only that action is intended (e.g. only one input from the buyer) but this of course means transactions with two inputs form the same PubKeyHash will fail.

So, if in order to sell some tokens you only need to pay a certain amount of lovealces and you don't require anything else; then you should check for anything else, allowing the transaction to succeed no matter the number of inputs, as long as the user paid the correct amount

this allows you to reduce your script size and often also optimize script execution.

the example of Plutonmicon says that if the user builds a transaction that doesn't respect the schema expected by your script, you should simply not care about it;

Why care about adding additional code to fail a transaction that would have failed anyway?

2
  • But in my case transaction wont be failed anyway. Worried about buyer's balance - the possibility of theft of a certain amount of Ada. This can happen if we have "dishonest" off-chain code and on-chain part without checking that transaction outputs are only assigned to seller or buyer and nobody else. Value of spent script output should go back to seller. And without specifying amount of Ada in each output, we can't say exactly how many buyer's Ada it will take for creating new seller's output. If there can be price of tokens < 1 Ada or even free. However, maybe i am just too scrupulous Sep 18, 2022 at 13:09
  • What you are describing is logic that is necessary to the smart contract; so no problem with that. You should not check for example for the Data to be built as you wish, because honest users will build the Data as intended, and if that is not the case then transfoming Data to a value already fails Sep 19, 2022 at 18:42

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.