Here is my code currently it ends up sending all of the value on the script to the caller but I only want it to send 1 ADA. How do I fix this? Is there anyway to create a smaller output to send

purchase :: AsContractError e => MintParams -> Contract w s e ()
purchase mp =  do
    utxos <- fundsAtAddressGeq valAddress (Ada.lovelaceValueOf 1)

    let redeemer = ()
        pkh = ownPubKey
        tx       = collectFromScript utxos redeemer

    void (submitTxConstraintsSpending lootBox utxos tx)

1 Answer 1


Because this is a utxo system all utxo's must be consumed and the outputs must balance. In the above case, if I understand your code correctly, the redeemer is the unit () which always passes. As such, any input/output consuming the contract would be accepted. You could send 1 ada to someone and send the rest back to the contract's script address (with fees subtracted) to do what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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