5

How do I get the datum of an output from cardano-graphql (or another service)? I have attached it using the --tx-out-datum-embed-file flag already when building the tx using cardano-cli.

Thanks!

1 Answer 1

4

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
Column name Type Description
id integer (64)
tx_id integer (64) The Tx table index that contains this redeemer.
unit_mem word63type The budget in Memory to run a script.
unit_steps word63type The budget in Cpu steps to run a script.
fee lovelace The budget in fees to run a script. The fees depend on the ExUnits and the current prices.
purpose scriptpurposetype What kind pf validation this redeemer is used for. It can be one of 'spend', 'mint', 'cert', 'reward'.
index uinteger The index of the redeemer pointer in the transaction.
script_hash hash28type The script hash this redeemer is used for.
datum_id integer (64)

datum

A table containing Plutus Data available in the blockchain, found in redeemers or witnesses

  • Primary Id: id
Column name Type Description
id integer (64)
hash hash32type The Hash of the Plutus Data
tx_id integer (64) The Tx table index for the transaction where this script first became available.
value jsonb The actual data in json format

Taken from dbSync:

https://github.com/input-output-hk/cardano-db-sync

It is also possible by just inspecting the blockchain. Even tho only the Datum hash is attached to the eUTXO, the datum value should be in the witness set of the transaction that created such eUTXO, so we should be able to:

a) Get the datum hash from the eUTXO and then.

b) Get the transaction that created such eUTXO and use the hash to retrieve the actual datum data.

Otherwise, if the Datum were not present at all on the chain it would be impossible to re-validate the blockchain from scratch.

2
  • As per the comments on this PR the datum is included in the TX that spends the corresponding eUTXO rather than on the one that creates it. github.com/input-output-hk/cardano-db-sync/issues/1076
    – Jesuspc
    Mar 7 at 21:43
  • It is possible to just add the datum hash when creating a transaction, in which case the actual datum value won't be included in the witness set of the transaction that creates the output, however, it is also possible to add the datum value at creation of the transaction if you use the flag "tx-out-datum-embed-file" or "tx-out-datum-embed-value" on the CLI and add the datum value, in which case, the datum value will be available on chain from the creation of the eUTXO. Mar 8 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.