1

I have an interesting use case for permanently storing an arbitrary hash string somewhere "reliable" publicly and, very important, with a trustworthy timestamp. For me, this sounds like a case for a blockchain application. As I feel a diffuse kind of sympathy for the Cardano project, i thought "why not start here". Let me explain a bit:

The idea is to create a strong hash (SHA2-256 or the like) of arbitrary data (text files, photos, combinations of these, ...). This part is easy. I don't need a blockchain for that and there are many well established standards for doing this. But now I also want to be able to reliably prove, forever, 'til eternity, that this specific hash existed at a certain time.

My first thought was, well, couldn't I just push this hash to a blockchain somehow? I mean, each transaction has a public timestamp that can't be messed with, right? Does Cardano allow for appending metadata like an arbitrary hash string to a transaction? Should I mint an NFT which holds this data? Then again, wouldn't that be overkill for my use case? What are the technical possibilities I could try to work with, here?

I am a developer, but my insights in blockchain technology are quite rudimentary. So I hope that someone can help me out by pointing me in the right direction. Thank you in advance!

3

Does Cardano allow for appending metadata like an arbitrary hash string to a transaction?

I believe you can do this without needing any tokens/NFTs by just making a transaction that has the metadata attached:

https://developers.cardano.org/docs/transaction-metadata/

This can be done using the --metadata-json-file switch when building the transaction:

cardano-cli transaction build-raw \
  --tx-in dfb99f8f103e56a856e04e087255dbaf402f3801acb71a6baf423a1054d3ccd5#0 \
  --tx-out $(cat payment.addr)+0 \
  --metadata-json-file metadata.json \
  --fee 0 \
  --out-file tx.draft

https://developers.cardano.org/docs/transaction-metadata/how-to-create-a-metadata-transaction-cli#submit-to-blockchain

2
  • 1
    This is great. TIL. Jul 23 at 23:05
  • 1
    It really is! Thanks a lot! I wonder how I could miss this reading through the docs...
    – bkis
    Jul 24 at 8:59
2

I'm sure there is more than one way to do this. Tokens can include metadata and depending on what behavior you want you could structure it different ways.

A couple of options come to mind:

  1. Use the Cardano CLI to add hash string to the metadata of a token
  2. Write a smart contract that owns an NFT with the hash string as data

I would first look at the Cardano CLI and see if creating a simple NFT would be good enough for you needs. It's been a minute since I dug into that stuff, so not positive if it will be enough.

If you wanted to do this with a Plutus smart contract, you could have an NFT containing the data owned by the script. This would allow other people, and in theory other smart contracts, to read the hash.

This could look similar to the Oracle Example from the Plutus Pioneers Program. Yours would be simpler because it wouldn't allow the creator to update the value like an oracle.

Essentially it will allow people to consume the hash data on the NFT as long as they return it in the same state they found it. This could also guarantee that you can always find it at the same place, rather than some NFT that could be transferred to different wallets.

Full discretion, this isn't trivial and you'd need to learn how to write/modify the smart contract as well as deploy it. Not to mention, smart contracts are only available on limited test networks as of writing this.

Hope this helps :)

1
  • 1
    Thank you for your answer, it was helpful in that it added some good ideas to the case. I think you'll understand I accepted the other answer for it's significantly smaller overhead, though :)
    – bkis
    Jul 24 at 9:01

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.