/ TAG Group

Storing data on the TAG Blockchain (and why)

It's been possible to store tiny amounts of info on the Bitcoin blockchain for many years, but it will cost whatever the transaction is (these days anything from $2 to $5), so a lot of what we are developing at Tagcash needs the ability to do the same thing, using the TagCoin blockchain. The method of creating transactions is slightly different, so we have had a blockchain programmer study the code and create code libraries we can use to connect into our API, and now we have the ability for anyone to write data and retrieve it.

This post will show you how, but first why would we want to do this and what exactly can we store?

Blockchains store data on an immutable database. Once written it cannot be changed. It is a record-keeping mechanism that makes it easier and safer for businesses to work together over the internet, especially when there is no trust. The amount of data that can be stored is tiny, otherwise blockchain ledgers would be huge and unwieldy. In fact, the usual amount of data is a max of 80 characters per transaction. So you could for example, store your name and a short message, a sort of digital graffiti that can never be erased. So be careful what you write, it might come back to haunt you one day.;)

So if we can only store a max of 80 characters, what good is that?. Well, that is where hashing comes in. A hash function is any function that can be used to map data of arbitrary size to data of fixed size. So you can run a hash function (sha256 for example) on an image, and it will return a 64 character hash. Another person can run the same image through that hash function to return the same hash, proving that the image is the same.

So lets say we want to store 3 images in an accident situation. You create a hash of each picture, then you create another hash of all 3 of those picture hashes to create yet another hash. Then you store that hash in the blockchain and get back a transaction ID - A few months later in court, you could then prove that the pictures shown were not faked, retouched, or changed in anyway since that first registration. This can apply to pdfs, documents, contracts, pictures, code, videos or any digital file.

Do a websearch for "create hash" and you will have lots of sites that can quickly make a hash of your data, ready to store. Or you can just add up to 76 characters of text.

So how to store some data into the TAG Blockchain?

First you will need to create an account at http://tagcash.com, and then create a merchant account which takes a few seconds and is free. Go to the developer page and get your Client_ID and Client_Secret, ready to create tokens to work with the API. I use Postman (https://www.getpostman.com/postman) to test and play with the API. So using Postman, enter your Client_ID and Client_Secret, along with grant_type which is client_credentials. https://api.tagcash.com/oauth/accesstoken/

Then you can run the 2 commands to either store or retrieve data into/from the TAG Blockchain

I will store some text "Blog Posting written for markvernon.org" along with an Identifier in this case my name "Mark Vernon"

https://api.tagcash.com/tagcoin/SendDataBlockChain

So this has now been recorded and I now have a transaction ID I can search for on the blockchain. I will do that in a moment, but first let's just retrieve the same data using the other API command and the transaction ID I received when posting the data which is - "5e64e16a941459a4e6600ad9874ff891698df570ac5b573bc7970744acb0055b"

https://api.tagcash.com/tagcoin/GetDataBlockChain

And Voila!, there is the message retrieved. I can confirm this by searching on the TAG Blockchain using 2 commands and a hex converter. The 2 commands are "getrawtransaction" and "decoderawtransaction". I can do this via the command line on a TAG Wallet or using the GUI wallet, using the Debug Screen.

So the part I want is in OP_RETURN which is the script in TagCoin that stores the info and the part I want is the hex (This is a method of storing data that is more efficient that normal text characters) so I need to run that through any hex to text converter. The hex is "6a334d61726b205665726e6f6e00426c6f6720506f7374696e67207772697474656e20666f72206d61726b7665726e6f6e2e6f7267" and we remove the the 6a and 33 (indicating use of OP_RETURN) which leave us with
"4d61726b205665726e6f6e00426c6f6720506f7374696e67207772697474656e20666f72206d61726b7665726e6f6e2e6f7267". When you run it through a converter you will see the text I originally stored:

So there you have it - an easy way to write data into the Blockchain, for whatever purpose you may want. This will only be free for a few more days, and then you will need to have Pesos or TagCoin in your merchant wallet to be able to do it. It will probably be 1 TAG or 20 pesos to create the record, but can be negotiated down depending on how many records you want to write.