How to get started with metadata on Cardano

How to get started with metadata on Cardano

(Written by @ElliotHill of the Cardano Foundation)

Blog_Jan20

On 18 January 2021, Jeremy Firster and Mel McCann from the Cardano Foundation’s integrations team delivered a workshop on transaction metadata. Together with Alan McSherry and Ben O’Hanlon from IOHK, Jeremy and Mel introduced transaction metadata and discussed its potential for building applications on Cardano.

Here, following on from the Metadata Workshop, we are going to take a closer look at what transaction metadata is on Cardano, explore how metadata can be added to a transaction and viewed, and discover some potential use cases for metadata.

At the end of this article, we will be sharing some resources, documentation, and links to video walkthroughs on how to get started with metadata.

We will also be challenging you, our developer community, to build solutions using metadata. As one of the first fully available features of Goguen, we think metadata has enormous potential.

More importantly, metadata could be the first significant stride towards making Cardano the financial and social operating system of the future, and you should think about how you can build using metadata as you read this article!

What is transaction metadata?

Transaction metadata allows data to be added and stored on the Cardano blockchain. The data that can be expressed through metadata are diverse, from numerical data to written details, and many other things in between. We can think of transaction metadata as ‘proof of utility’, ensuring that data can be validated and giving assurance to transactions.

In one of our testnet environments, members of our community have already immortalized the Cardano whitepaper through transaction metadata—publishing the entire document through a series of transactions that will live on the Cardano blockchain as long as it exists.

Transaction metadata can enable you to provide context about a specific transaction. This could include any comment or information on the transaction itself, such as sender and receiver identification, historical ownership of the asset, transfer information, and also certification and validation information—which we will discuss in more detail below.

Examine the example transaction metadata above. Here, we created a simple message inviting people to join the Metadata Workshop on Monday 18 January 2021. As you can see, the cost to send this transaction was just ₳0.19, which is an incredibly small fee to send something that will essentially be stored forever on the blockchain.

In this example, we used some simple text attached to the transaction to send a message. But there are multiple other ways that you could use metadata to represent diverse data.

The great thing about metadata on Cardano is that it is all available through generic components, available to use right now on the Cardano mainnet. So, let’s discover the first steps required to add metadata to a transaction.

How do I add metadata to a transaction?

In the Metadata Workshop, Alan McSherry from IOHK ran through the process of creating a transaction with metadata on Cardano.

We recommend rewatching the Workshop here, and navigating to 11:20 where Alan’s walkthrough begins. You will need to access some of Cardano’s API infrastructure to attach metadata to a transaction. It is not currently possible through Daedalus wallet or other ada wallets.

To make it easier to navigate to the resources you will need to add metadata to a transaction, you may find the following links useful:

The size limit for data added to transaction metadata is 16KB. This seems small, but in fact, it’s more than large enough to include descriptive data. For example, in the case of Scantrust and Baia’s Wines, an entire batch of wine could be certified using just 1KB of transaction metadata in just one transaction—rather than making a separate transaction for each bottle.

The fees associated with adding metadata to a transaction serve two functions. There is a constant fee, which is designed to prevent misuse of the feature by making large-scale attacks fairly costly to the bad actor. This is set at ₳0.155381. There is also a minimum fee associated with on-chain data storage costs. This is set at around 43 lovelace, or ₳0.000043946, to be precise.

From these fees, we can calculate the exact cost of attaching metadata to a transaction if we know the size of the metadata. We can use the formula A+(B×C)=X, where ‘A’ is the constant fee, ‘B’ is the fee associated with storing the transaction on the blockchain, ‘C’ is the size of the transaction, and ‘X’ is the transaction cost.

In any event, with a maximum metadata size of 16KB, the transaction costs are low.

Where can I view transaction metadata?

All metadata associated with a transaction can be viewed on-chain, using an explorer that enables the viewing of metadata, or using a CLI interface. Cardano is unique in allowing metadata to be easily viewed using a standard blockchain explorer, which makes it a much more useful and rich experience for developers and enterprises alike.

As you can see from our example above, we have used adastat.net, but there may be other chain explorers that you can use for this purpose—or you could create your own!

What are the potential use cases of metadata?

So, now you know that you can add data to a transaction. In isolation, this may seem like a relatively simple and small feature. But actually, the contrary is the case. Transaction metadata is a powerful and diverse feature that could form the basis for a multitude of solutions built atop Cardano.

As we move through Goguen, we have talked a lot about the infrastructure required to power decentralized applications and real, tangible use cases for Cardano—and transaction metadata is the first fully available of such features on Goguen.

We want to challenge the developer community, both inside and outside the Cardano ecosystem, to build using transaction metadata.

The Cardano Foundation’s work with supply chain tracking technology provider Scantrust, and Georgian winemakers Baia’s Wine, is one great example of how metadata can be leveraged for commercial use. We describe this use case in detail here.

Now, we are going to describe some of the other potential use cases we envisage metadata powering—in other words, solutions that you can begin building today. Just as the Cardano Foundation used metadata to power the first commercial application on Cardano, you could also design an application that makes use of metadata.

There are four major applications of metadata, these include:

  • Validation and verification
    As the Cardano Foundation has shown with Scantrust and Baia’s Wine, metadata can be used to validate and verify external physical products and genuine articles. This requires pairing with a physical identifier, such as a QR-code, but it is particularly useful for supply chain tracking of fast-moving consumer goods, at low cost.

  • Authentication and attribution
    When you receive credentials from an educational institution, membership organization, or similar, there are usually physical identifiers to prove their authenticity. For digital courses and accreditations, this is more difficult. A transaction with metadata attached could serve as an immutable and always-accessible proof of certification, for a low fee.

  • Secure record of information
    Metadata attached to a transaction and confirmed on the Cardano blockchain is immutable. This means no one can change or tamper with it, and it lasts as long as the Cardano blockchain exists. This is a great way to store and back-up information that is important, or could even just be used to leave a fun message for the future.

  • Timestamping
    Timestamping is useful for any transaction which requires payment details to be attached, or for the history of ownership of certain assets. Metadata can be used to create a timestamp within a transaction, allowing anyone to verify the time and date at which something was bought, sold, or transferred.

Essentially, metadata can be used to tell the story of a transaction. When paired with off-chain infrastructure, such as physical identifiers, metadata can serve as a confirmation or assurance of authenticity.

Importantly, metadata shouldn’t be abused to store any kind of data on the blockchain—only information that benefits from the applications described above. We hope the above examples can help those interested in metadata to come up with solutions and applications which leverage its many benefits.

Resources and next steps

We hope that this article has further armed you with the knowledge to use metadata for solving complex problems with Cardano. We now openly challenge our developer community to innovate and explore the opportunities that transaction metadata offers.

If you have a good idea for using metadata, we would love to see a proposal put forward for the next round of Catalyst funding. The Cardano Foundation believes that applications leveraging metadata will be the kickstart to Cardano’s DApp ecosystem.

As such, our integrations team and others at the Cardano Foundation will assist those looking to use metadata in applications in any way we can. If you have any other questions, why not start a discussion on the Developers section on the Cardano Forum? You can also make use of the following resources:

We are already really pleased to see the response of our community to our Metadata Workshop. If you are short on time and want a succinct recap of what we learned, you can read this Twitter thread by Daniel Ribar, where he details the key features of transaction metadata on Cardano.

We look forward to seeing what you create with metadata on Cardano! Have fun and keep building.


Read more about building on Cardano here:

18 Likes

Good to know, thanks.

1 Like

Are there plans to have metadata functionality inside the wallets?

1 Like

Yes of course, sooner or later all the wallets will support this.

1 Like

Might be a feature request, since I can’t find this anywhere but It might create some interesting use-cases if the call to delegate also has a metadata parameter

1 Like

Do you know if there is any wallet that supports metadata already?

1 Like