I have been looking into creating a blackjack game on the Cardano Blockchain. I started with learning Haskell, and writing a simple blackjack CLI game. It was heaps of fun and a bit of a learning curve since I have never used functional languages before!

Unfortunately I misunderstood one critical thing about Plutus apps which mean that I could never implement this game in a truely decentralized way. That misunderstanding is that I could run arbitrary code and transform the datum in the on-chain code. This is true on Ethereum but not in Cardano, where the on-chain code can only determine if a transaction is valid.

I can't see any technical reason why a datum transformation couldn't be performed on a single UTXO, apart from performance considerations. So my main questions are:

  1. Is there any technical limitation preventing Cardano from implementing this functionality on L1 in the future? Or is it just to prevent L1 from becoming bloated with excessive datum storage and code execution?

  2. Will there be a layer 2 that allows this functionality? Is this the idea of IELE?

Appreciate any clarification here!

  • I should clarify that I need to draw a random card and update the state on-chain for this to be a truely decentralized app. It's true that I could probably setup some oracle off-chain to draw a card and update the game datum but this would be a lot more complex and a lot less decentralized.
    – micwallace
    Commented Dec 28, 2021 at 3:35
  • 1
    Even if you had the functionality to change the datum on-chain, you would not be able to draw a random card. On-chain code is deterministic. Randomness can never be achieved, therefore. This is also true in Ethereum where you couldn‘t implement this as well. You can ask yourself, how would any node be able to verify that the card was really drawn randomly by another node of the network ? It is simply impossible: randomness cannot be proven and is therefore not implementable on-chain.
    – Jey
    Commented Dec 28, 2021 at 8:27
  • @Jey At least not until we have verifiable random oracles on chain
    – zhekson
    Commented Jan 27, 2022 at 21:45

2 Answers 2


You're right, data transformations can be performed on UTXO's, and, to your first point, any app that requires rapid and/or complex data transformation produces too much bloat, as each transformation would produce at least one new UTXO.

Lil' Cardano Design Philosophy Review:

The "main-chain" (a.k.a., The CSL, Cardano L1, e.t.c.) is best suited for the settlement of data and logic, while a diverse ecosystem of "side-chains" (a.k.a. CCLs, Cardano L2s, e.t.c.) are best suited for execution of said data and logic. The extent of this bifurcation can be decided upon by the developer(s), and will vary widely depending on the security and throughput requirements of the dApp. Ultimately, it will be up to the dApp developer(s) to decide on a particular structure that makes sense.

In a PvP game like poker, settling and executing every move on main-chain can be done, but it would be slow, expensive, and uninspiring. Instead, players/clients can commit their UTXOs as inputs-to-be-operated-on to a Hydra Head. Head operators can engage in data transformation that is only limited by their own network throughput, while periodically committing snapshots back to the mainchain for dispute resolution.

(FYI: maintaining high composability while bifurcating settlement and execution of logic is the essence of Cardano's ability to scale limitlessly)


Having a validator script with the ability to change the datum would not increase the power of Cardano's smart contract model. The reason is that, in the current model, validators can only use (as inputs to their logic) data that the transaction provides. The validator cannot run anything that the submitter of the transaction cannot also run. It makes, therefore, no difference if the datum is computed on- or off-chain.

The real reason you have the impression that the Ethereum model is more powerful is that, on the Ethereum blockchain, a smart contract can use the whole blockchain at execution time as input for its computation. This also means that the submitter of the transaction cannot know for sure the result of the smart contract execution as the blockchain could have changed between the moments of submitting and executing the transaction.

The biggest difference I see between Ethereum's and Cardano's smart contract models is that on Cardano it is more difficult to implement some uniqueness constraints in a decentralised way. For example, a minting policy cannot make sure that a token name is unique if the token name space is too large to fit into a script datum. A trusted party is necessary to enforce this uniqueness.

Apart from this, a random number generator is impossible on-chain and no existing blockchain implements one. Randomness always needs to be pushed to the chain from the outside world. This can be done by the means of oracles or by signed random numbers of a trusted off-chain source.

  • I'm not sure if you understand the question. I completely understand what UTXO is and no way calling Ethereum superior! But Cardano validators as they stand can only classify a transaction as valid or not. They still have access to the datum of the input UTXO/s to determine validity, but they cannot run code to set the outputs or datum of transactions that try to consume that UTXO. I don't see how not having access to the global blockchain state would be an issue here, hence my question.
    – micwallace
    Commented Dec 29, 2021 at 11:49
  • Also there are a few ways of getting random numbers on-chain, it's not impossible.
    – micwallace
    Commented Dec 29, 2021 at 11:54
  • I understood your question. Maybe you did not understand my reply. Also, I did not imply that you think Ethereum is superior. “Powerful” is meant in the programming sense.
    – Jey
    Commented Dec 29, 2021 at 13:10
  • Maybe it is not clear to you that the validator script really has access to nothing except the inputs; not even to the slot number. It is purely functional.
    – Jey
    Commented Dec 29, 2021 at 13:17
  • 1
    No, by inputs I meant the whole transaction. This transaction already includes the updated datums. So in a way, the model does already what you are describing. There is no need to have the validator return anything else than a boolean.
    – Jey
    Commented Dec 31, 2021 at 7:46

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.