user5801: Which TxConstraints i o method should I use to create a transaction where the script pays a specified amount to the wallet? The mustSpendScriptOutput is the only one I can find that sends tokens from the script to the wallet, but it sends all the tokens at a utxo. I am looking to send a specified amount, and the change is returned to the script.

user5085: UTxOs can only be consumed completely which means you will have to create a new output at the script address that receives the change that shall stay with the script which can be done via mustPayToTheScript <datum> <value>.

5801: <p>Which TxConstraints i o method should I use to create a transaction where the script pays a specified amount to the wallet? The <code>mustSpendScriptOutput</code> is the only one I can find that sends tokens from the script to the wallet, but it sends all the tokens at a utxo. I am looking to send a specified amount, and the change is returned to the script.</p>
 5085: <p>UTxOs can only be consumed completely which means you will have to create a new output at the script address that receives the change that shall stay with the script which can be done via <code>mustPayToTheScript &lt;datum&gt; &lt;value&gt;</code>.</p>
