0

I know that you can use collectFromScript to take all of the value from a script but is there a way to make it so you only take 1 ADA from a Script that holds 100 ADA?

Thank you

1
  • This question was asked again in more elaborate form a few hours later here: link. Please edit questions rather than splintering them; that keeps our Stack Exchange concise and more useful.
    – Hysteria
    Commented Feb 5, 2022 at 2:54

2 Answers 2

1

Yes. You can just write a grab transaction where the whole 100ADA utxo gift is consumed by creating 2 utxo outputs: 1ADA for the grabber and 99ADA back to the script perhaps with a script update pointing to new output address.

If the 100ADA gifts are made up of smaller UTXOs then just choose from those.

2
  • How would I do this what functions in the Plutus library should I look up?
    – Floof99
    Commented Jan 23, 2022 at 20:01
  • If you look at homework 2, what one can do I think is use the grab function. utxos in that function has a list of all utxos from address/ One can 1 ADA from that for the grabber then call the give function within grab to send the 99 ADA back to the script.This is all of course conceptual from me as I'm also just learning. I might try to play around with it and see if I can implement it.
    – d_fajardo
    Commented Jan 24, 2022 at 9:13
0

No, it's a utxo system, so any inputs need a corresponding output. Now, the output could be to the script address itself depending on how the smart contract is written. The NFT auction from week 1 of Plutus pioneers showed how this is done for example.

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.