Hot answers tagged

7 votes
Accepted

How can I enforce a datum type to be correct?

Hopefully I'm following your question... I'm not aware of any type checks performed at validation, but I'm also not aware of any situation that a validator/script would need to spend resources ...
user avatar
4 votes
Accepted

Plutus pattern/technique for finding original datum preimage of TxOutDatumHash?

Datums are stored on-chain. There is part of PAB called chain-index - it follows the node, pulls Datums and stores them in local database (see here section Plutus Application Backend). So for your ...
user avatar
4 votes
Accepted

How do I read the datum of an output?

If you are running a DbSync node you can retrieve the datum and redeemer: redeemer A table containing redeemers. A redeemer is provided for all items that are validated by a script. Primary Id: id ...
user avatar
3 votes

Is there complete cardano-cli documentation?

The flag --tx-out-datum-embed-file FILE allows you to embed the datum data on the transaction, not the datum hash like using that flag --tx-out-datum-hash-file FILE. cardano-cli transaction build --tx-...
user avatar
  • 1,597
3 votes
Accepted

A Script With Multiple Different Datum Types

let's say we have a Maybe Integer type, then the value must be assigned as either Just 3 or Nothing. Directly assigning it as 3 won't work. So your QuadraDatum should be created as let dat = ...
user avatar
3 votes
Accepted

Is it possible to send funds to a scriptAddress using a lightweight wallet?

This answer will surely age fast. At the time of writing both Nami V3.2.0 and Yoroi Nightly 4.11.501 allow you send to script address, but neither advertise any options of setting datums. Nami allows ...
user avatar
  • 313
3 votes
Accepted

What is the mkValidator Script

A validator script locks transaction outputs. This function is where you define conditions to unlock them. https://plutus.readthedocs.io/en/latest/plutus/tutorials/basic-validators.html
user avatar
  • 333
3 votes
Accepted

How to create Datum with ownPaymentPubKeyHash?

You are using the operator <- to bind the result to pkh. That means that pkh is of type PaymentPubKeyHash. If the equality fails then because of another reason. If pkh wasn’t of the right type you ...
user avatar
  • 1,256
3 votes
Accepted

Plutus datum and redeemer on cardano-cli

Have a look at the following source Cardano-Api Haddock. Here you will find all about the conversion between Haskell data types and the Json format the cardano-cli uses. I noticed that you used the ...
user avatar
  • 803
3 votes

Get Value of Datum from a UTXO

The upshot is that you might not find a datum but instead get a hash of the datum (it depends). When submitting a transaction the full "unhashed" datum is not automatically attached to the ...
user avatar
  • 803
2 votes

Is Redeemer similar to <ScriptSig> in bitcoin context?

One way to think of it is that: The Datum is a piece of data that's attached to the UTXO by the producer, The Redeemer is a piece of data that's provided by the consumer, When the UTXO is consumed, ...
user avatar
  • 139
2 votes
Accepted

Ensuring NFT collection uniqueness using counter as asset name?

This should work. I don't see any obvious ways of tampering with it. As long as you are checking against the token name, not the currency symbol, these tokens would be non-fungible and unique. To ...
user avatar
2 votes

How can I enforce a datum type to be correct?

You should be extra careful with data that is being provided to smart contracts by the user. You might prevent user errors by using data from the Context that is already provided to you inside the ...
user avatar
  • 301
2 votes

What is where executed and when?

One detail to add here: In short: if another Tx generator wants to use the same script, but one or more blocks later, it will need the datum (previous state of the script), which must be exposed by ...
user avatar
2 votes

What is the mkValidator Script

On Cardano logic can be enforced on how UTxO's are spend by attaching a "script" to the transaction + some inputs that will be used to run the script (the datum, redeemer and context). ...
user avatar
  • 803
2 votes

Plutus datum and redeemer on cardano-cli

{ "constructor": 0, "fields": {int: 42} } This isn't valid because fields must be an array. The index of the constructor and fields will match the order of types defined for the ...
user avatar
  • 333
2 votes
Accepted

Get Value of Datum from a UTXO

The ChainIndexTxOut type has a data field called _ciTxOutValue :: Value and another that is _ciTxOutDatum :: Either DatumHash Datum I'll show you how to get the value. Getting the datum is the same ...
user avatar
1 vote

Get Value of Datum from a UTXO

OffChain: It's a datum hash - so there is no reverse lookup if you don't know how to construct datums for a given contract. Datum values are usually provided by the consumer of a script UTxO. OnChain: ...
user avatar
1 vote
Accepted

How to provide Datum value using serialization lib

Thanks to Sebastien, there is an open issue for this. Github Feature Request Besides, one can attach the datum separately to the tx witness set, like so for example: const datums = PlutusList.new(); ...
user avatar
1 vote
Accepted

Different Data tyoes for datum

You can combine the two like this data DatumAction = VotingDatum | StartDatum Then you can specify in you validator which case is used like this mkValidator :: DatumAction -> redeemer -> ...
user avatar
  • 803
1 vote

PlutusData construction using @emurgo cardano-serialization-lib-browser

Maybe this will help, typhonjs supports creating plutusDataCbor using utility method const plutusDataBuffer = typhonjs.utils.createPlutusDataCbor({ constructor: 0, fields: [12, 12], }); const ...
user avatar
1 vote

Using custom datum for `mustPayToOtherScript` in off-chain code

As far as I know your datum types are required to conform the Data type. Try: PlutusTx.makeIsDataIndexed ''RandomDatum [ ('RandomDatum, 0) ] {...} let randomDatum = RandomDatum { ...params... } ...
user avatar
1 vote
Accepted

What is the role of datum in spending a transaction

I thought datum was used to keep track of the state of the script. It can be and often is. This is how its used in a StateMachine, for example. The cardano chain is 'lean': only the necessary ...
user avatar
  • 313
1 vote
Accepted

Missing datums in db-sync

As datums values are included in the witness set of the corresponding transactions This is not true all of the time. When you create a new script UTxO by sending some amount of tokens to it, you don'...
user avatar
  • 723
1 vote

What is where executed and when?

The blockchain does not only store hashes. It also stores the datum and the script of spent UTxOs. It would otherwise not be possible to validate the transaction in retrospect. So while you don't need ...
user avatar
  • 1,256
1 vote

How does Constraints.mustHashDatum work?

This is my beginner takeaway about Constraints.mustHashDatum after reading about TxContraints and TxConstraint and mustHashDatum at the Ledger.Constraints documentation link below. I will also be ...
user avatar
  • 11
1 vote

How does the final transaction in the auction example know who did the bid?

Each change in state in the auction contract passes a new datum (arbitrary data). The auction datum is made up of the 'Auction' and 'Bid' records. The bid record has a 'bBidder' field which is the ...
user avatar
1 vote
Accepted

How to pass TxOutDatumNone when building a script transaction with cardano-cli

I'm afraid that presenting a "none" datum is not possible. This also means that this UtxO is lost (anybody, correct me if I'm wrong) I don't know the very reason why it is possible to send a ...
user avatar
1 vote

Is there complete cardano-cli documentation?

I'm trying to learn this too. I could not find any further documentation other than the cardano-cli command help. This is pretty extensive and useful. Every command argument seems to have built-in ...
user avatar
1 vote
Accepted

How does custom Plutus data type map to cardano-cli --tx-in-datum-file content?

Here is an example of a haskell executable that will convert any of your custom data types to the right JSON format : https://github.com/OnChainLabs/Martify/blob/main/app/datum-json.hs In this file we ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible