Metadata in Cardano transactions
Cardano is to be a social and financial operating system. As such, it must be more than a transaction network on blockchain. It must be easy to extend the basic concept and add new functionalities. Transaction metadata will allow it.
Every transaction has a context
First-generation blockchains are able to store transactions. Every transaction basically says how many coins were transferred from address A to address B and when was it. There is no context that would say something more about transactions. Nobody knows who owns addresses, the reason why transactions were sent, and whether everything was fine regarding the interaction of counterparties. Only participants of a transaction know the context.
You probably would not expect more from a transaction network. PayPal does basically the same job. It just transfers money from bank account address to bank account address and does not care about the context. The difference is that third parties know participants but the principle is similar.
People are able to consume traditional financial services of third parties under the condition that they trust them. If they want to buy stuff on Amazon they just send money and they will receive ordered gadgets. If they want insurance they just send money to an insurance company and they will be insured. If they wish to borrow money they just ask a bank, put something into collateral and regularly pay off the loan. Every financial interaction requires sending transactions. There are made external agreements between parties and as a result, transactions are sent. The contexts of transactions are known only by parties that have made agreements.
Traditional bank transactions are able to bear some additional information that specifies their context. For example, a receiver of a transaction can ask the sender to insert some number into it. The number is used by the receiver to understand the context and properly handle sending money. For example, the number can be related to the ID of an agreement between parties. Is that important? Definitely. When auditors come to a bank they might wish to understand all transactions that were received by the bank. It must be easy to explain why and from whom a given transaction was accepted. In some cases, the transaction contexts inside transactions are a necessity. Transaction context can be useful between friends or business partners. If they wish to insert some information into a transaction they can easily do so. It can even be a piece of text.
It is actually very easy to insert the context information into traditional transactions. If transaction context is useful in the traditional financial world then it would also be useful in blockchain transactions. Moreover, it must be easy for users to insert the context via blockchain wallets.
To be able to work with transaction contexts will be more important when people will start building decentralized companies and banks. It is not the case now since people mostly hold cryptocurrencies or send coins to friends or exchanges. Once we want to build decentralized financial services then we will need to work with the context. We basically want to avoid trusting third parties and put trust in decentralized technologies. To do so, Cardano must be technologically well-armed to provide good decentralized services.
What is transaction metadata?
Metadata is a piece of digital information that can be inserted into a Cardano transaction by the sender. Metadata will be stored in the blockchain together with the transaction. Everybody can easily find any transaction stored in the Cardano blockchain so everybody can also see metadata.
It is important to mention that the information will be immutable in the same way as the transaction itself. Moreover, only a sender can sign a transaction by the private key so it is basically proof that the sender inserted the context into the transaction.
Metadata can be whatever a sender and/or receiver consider meaningful. It can be a text, specific structured text, number, hash, a combination of that, etc. If the context of metadata should remain secret then it is the responsibility of the sender to encrypt it.
Metadata can have a maximum of 16KB in a single transaction. So, you cannot store a movie into the blockchain. 1 character can be represented by 1 Byte so it can be said that you can insert 16K characters. For your imagination, a standard A4 page, written in 12–14 fonts, has approximately 1800 characters. You would be able to store Bitcoin whitepaper into the Cardano blockchain in a readable form.
Would you need to store more data and have proof that nobody has changed the content? For example, you would want to store all scientific studies published by the IOG team. It is around 50 papers. Every paper can have tens of pages. Is it possible to store it in one transaction? No, but common practice is to create a digital fingerprint (hash) and store it instead of the original text. The text is then stored externally. The digital fingerprint can be later used to verify that the reader has the text that has not been changed. In other words, that it is the original form of the document. The digital fingerprint is actually very short so it is possible to do one for every paper and store all of them in a single transaction.
How much does it cost?
Inserting metadata into a transaction and storing it cost something. The transaction is bigger so it consumes more resources. Hence, the sender must pay a higher fee when metadata is inserted in the transaction. The minimum fee for inserting metadata is ₳0.155381. The fee should prevent misusing the feature by spammers that could spam the network. Moreover, there is a minimum cost for storing data on-chain. It is set to ₳0.000043946 per Byte.
To calculate the fee is quite straightforward and you can use the following formula:
A+(B×C)=X
The letter A stands for the fixed fee for the insertion of metadata. It is ₳0.155381. The B stands for the price of storing one Byte and it is ₳0.000043946. The C stands for the number of inserted Bytes. The X stands for the total fee for the insertion of metadata.
So, if a recipient asks you to insert ID “4578125478” into a transaction then you would pay:
₳0.155381 +(₳0.000043946 × 10) = ₳0,15582046.
How can metadata be used?
The potential of metadata is tremendous and it opens a lot of utilities. Some might argue that addresses of participants and transaction ID could be sufficient and we do not need more pieces of information. We do not think so. For example, the link between a blockchain address and the owner might not be sufficient for the identification of the sender. The recipient can generate an address for the sender and knows the context. But what if there will be more transactions for more independent recipients. What if we wanted to create a trusted transaction history of the sender? The sender might wish to use more wallets so how to prove that all transactions have been sent by one sender? The transaction context is the key. It could be easy to use an external decentralized (or centralized) identity management and insert a unique ID of the sender into transactions. The unique ID linked to the sender can be provided only by the sender that owns the private key of the identity. Thus, it would be possible to identify all transactions of the sender. Notice that the privacy could remain in the hands of the sender. The sender is able to prove that she has sent a lot of transactions. Is that useful? It depends on the context. If you wish to obtain a decentralized loan then it can be useful to prove that you have paid off some in the past or regularly pay for electricity.
Metadata might not be necessarily related to the transaction itself. Transactions can be used as the bearer of the information and the way how to store it into the blockchain. In other words, it does not matter who sends a transaction to whom. The senders can use their own addresses. Stored information has the same qualities as a common transaction. It is immutable, publicly available, and verifiable. The time of storing the information and the identity of the sender (if the private key is not compromised) cannot be changed.
This feature can be used by parties that need to issue digital proof that somebody has received some certification or diploma. This information can be stored in the blockchain. Everybody can find it and verify that it was issued by the expected issuer. An owner of the certification can easily show the information in the blockchain and prove it to others. There is no need to use paper certifications and diplomas that can be easily forged. Using blockchain is much safer, more trusted, and it can be cheaper.
This feature is also very useful when you need to prove that something existed at a given time in the past. It can be an agreement, digital data, or whatever. It does not matter whether the original content or the hash of the content is stored. If an agreement is stored, including digital signatures, then nobody can deny the existence. If you invent something or have some secret you can create a hash of the document and store it in the blockchain. You can later prove that you knew it in the past.
Conclusion
Developers of applications can use cryptography and put it together with the decentralized services and immutable blockchain. The combination is very powerful. Metadata can be used also by smart contracts and Atala Prism (decentralized identity management). The IOG team provides building stones and it is actually on developers to create decentralized services and new functionalities.