7

In the Gift.hs example from the second lecture in Plutus Pioneers Program, when I give ada, a UTxO is produced. When I want to grab that ada in the same block, it fails (There is no input or output when simulated in the palyground). But when I wait for one block and then try to grab, It succeeds.

My conclusion is we cannot produce and consume a UTxO in the same block. We can only consume a UTxO from the next block onward. Am I right or...?

3 Answers 3

7

That is correct. For a UTxO to be consumed it first has to exist on the blockchain. For it to exist on the blockchain the transaction that created it must exist in a block that has been confirmed by the network.

3

You can only grab the gift once it's confirmed on the ledger. Search for awaitTxConfirmed in the source code.

That effect may have configurable level of confirmation in the future as indicated in the source code.

1

It is possible, at least with a recent version of cardano-cli (don't know about earlier ones, but I assume it would work too) to issue two transactions sequentially where the output of tx n is used as the input of tx n + 1. Both transactions will be put into the same block.

Here's a block where I've done so a few days ago, the first two transactions are by me. You can see that the second tx uses the first one as input.

Edit: In the context of plutus smart contracts however, I think Matthias is correct.

1
  • This isn't a limitation of Plutus scripts in general, but the plutus-contract library. Transaction chaining is possible with and without Plutus scripts involved.
    – james
    Oct 6, 2022 at 8:06

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.