Skip to main content
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 ...
Mitchell Turner's user avatar
5 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 ...
Fermat's user avatar
  • 1,872
5 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 ...
AngelCastillo's 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 ...
Mikhail Lazarev's user avatar
4 votes
Accepted

Is function "isPayToScriptOut" unsafe?

Your deductions are partially correct. isPayToScriptOut looks at the credentials of an address (1) and return true if it is a script address, false if it is a public key credential. It thus does not ...
Fermat's user avatar
  • 1,872
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/tutorials/basic-validators.html
james's user avatar
  • 1,560
3 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). ...
Fermat's user avatar
  • 1,872
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 ...
waalge's user avatar
  • 403
3 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 ...
james's user avatar
  • 1,560
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 ...
Jey's user avatar
  • 1,521
3 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, ...
insitu's user avatar
  • 224
3 votes
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 ...
Jean-Sébastien Gonsette's user avatar
3 votes

How can I secure a Datum value in a smart contract?

There are multiple ways to do that. Option 1: If you have "script-wide" constants, like your mentioned example of an auction house fee, I suggest parameterizing your contract like it is done ...
Will's user avatar
  • 1,162
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 = ...
Sudip Bhattarai's user avatar
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 ...
Fermat's user avatar
  • 1,872
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 ...
Mitchell Turner's 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 ...
andycandy's user avatar
  • 321
2 votes

How to specify the new output datum value (not hash) using the CLI

I already found the answer and will leave it here in case anyone ran into the same problem. You need to update the node-cli version to the lastest version (currently) 1.31.0 and then you have the ...
AngelCastillo's user avatar
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 ...
hsteamroller's user avatar
2 votes
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 ...
waalge's user avatar
  • 403
2 votes

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 ...
Mehul Prajapati's user avatar
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 ...
Kyle Murphy's user avatar
2 votes

Loading specific Datum JSON with Map structure into Plutus type

You could define a union type for values, something like data Val = B BuiltinByteString | M (AssocMap BuiltinByteString Val) type OrcFax = AssocMap BuiltinByteString Val then you can deserialise ...
insitu's user avatar
  • 224
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 -> ...
Fermat's user avatar
  • 1,872
1 vote

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

Mehul was correct. @strictahq/typhonjs does work correctly and produces the same result as cardano-cli transaction hash-script-data --script-data-file test.json Where test.json contents are: { "...
Eli Selkin's 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... } ...
Will's user avatar
  • 1,162
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'...
Mateus's user avatar
  • 988
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 ...
Jey's user avatar
  • 1,521
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 ...
phendi's user avatar
  • 11

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