7

submitTxConstraintsWith :: ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e Tx

How does submitTxConstraintsWith make usage of the ScriptLookups?

I always see it used like this: ledgerTx <- submitTxConstraints (swapInst oracle) tx

I am wondering why the ScriptLookups?

1 Answer 1

2

The family of submitTx functions all create transactions from the constraints submitted in the arguments. The most general implementation of the function is

submitTxConstraintsWith 
  :: ScriptLookups a 
  -> TxConstraints (RedeemerType a) (DatumType a) 
  -> Contract w s e Tx

Here ScriptLookups a takes a lookup of the (Plutus compiled) scripts that are required by the transaction for on-chain execution.

This link gives an overview of the functions that are implemented. I added it as illustration as I don't know what Plutus commit it belongs to.

2
  • So, the transaction that ends up being submitted to the network will have as output/UTXO the script, right? instead of say a public key hash for example. ? @vcwebco
    – Attilah
    Commented Aug 3, 2021 at 18:28
  • Not as output, but as constraint. In the case of a script the constraint is a validator that upon execution must return true for the transaction to succeed. The spending transactions that consume UTXOs from the smart contract need to supply validator script hash and (compiled) code. The producing transactions only need to supply the validator hash. It is explained in the Plutus Pioneer Program - Iteration #2 - Lecture #2 video at minute 37.
    – vcwebco
    Commented Aug 3, 2021 at 20:29

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