spacebudz / lucid

Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript, Deno and Node.js.
https://lucid.spacebudz.io
MIT License
339 stars 139 forks source link

Attaching a datum to genesis UTxOs in Emulator #213

Closed zing-rsa closed 1 year ago

zing-rsa commented 1 year ago

Considering we can assign arbitrary assets and arbitrary addresses in the emulator's genesis transaction, I can see a use case for attaching datums as well. For example, I recently would of liked to simulate a thread UTxO with a Datum at a validator address. An example implementation:

image

Since the genesis Tx creates a single UTxO at each address it would be fairly clear that the datum is attached to this UTxO. There might be quite a few other use cases, working with CIP68 ref tokens comes to mind. In these cases it would save from having to do a 'boilerplate' transaction to set the state first.

Wondering if this is feasible or if purposefully left out? I understand it might not be in line with the actual functionality of the blockchain and possibly because of that is not a good idea. Interested to hear thoughts.