RE: Exploratory Analysis Shows World of Opportunity with JSON and STEEM
Is this a limitation of the custom JSON field, where it cant be used like any database?
The custom_json transaction is not in any way a database. All the custom_json transaction is is a way to have a transaction that doesn't have any side effects. An example of a similar thing in Bitcoin would be sending 0 BTC to 0x0 with a certain message. That's all a custom_json does. If someone creates a custom_json transaction transfer krnel 5 cats
and that transaction is included in a block nothing happens. The Steem nodes don't add an entry to a database saying that now @krnel has 5 more cats or something. The only thing that happens is that now if you ask a Steem node what was in that block, you will see a bunch of transactions, one of them being a custom_json transaction transfer krnel 5 cats
. I could create a custom_json transaction saying sdadg asdgsad sdfasd asdf
and none of that would be entered in any database (not like there would be any reason to), but will be entered in a block.
So why would this be useful for DApp creation? All you can do is write a message in a transaction to the blockchain without any side effects. But what this means is that my Stratos DApp can look for when @alice creates a transfer_stratos
custom_json transaction. Then it can rely on a shared protocol; everyone running Stratos agrees that when someone creates a transfer_stratos
custom_json transaction, they decide that that means that they will update their internal ledger accordingly.
So let's say Alice creates a custom_json transaction transfer_stratos 10 bob
(this means 'transfer 10 SRTS to Bob', but written in a way that's easier for computers to understand). That transaction is included in a block, but the Steem nodes don't do anything about it. Again, they don't update a database or anything. They just include that transaction, charge Resource Credits, and ignore it. But Alice and Bob and many other users in Stratos have agreed that when anyone creates a transfer_stratos
custom_json transaction, they have an intent to transfer SRTS to someone else (again, this is just a shared belief and doesn't mean anything on the blockchain level). So when a Stratos node running the Stratos software (connected to a Steem node) sees the transfer_stratos
transaction and updates the internal balances to remove 10 SRTS from Alice's balance and add 10 to Bob's balance. Now every Stratos node agrees on this new update, and Alice has successfully transferred 10 SRTS to Bob (this actually means that every Stratos node agrees that the transaction happened, and so they updated their ledger accordingly).
Here's a post where I explain the same thing in more detail, including cases of malicious actors trying to hack the Stratos network, and explanations of how this relates to Steem Monsters and steem-state (note that this is before the rebrand from Engine to Stratos): https://steemit.com/steem/@shredz7/how-engine-works.
I'm glad to see you interested in this as it is a fascinating topic -- if you have any more questions feel free to ask!
Thanks. By database, I meant the blockchain that records data and can be accessed, but has permissions to prevent anyone from just entering any data they want on behalf of others, that there is a record of who enters data to validate it in some way.
For your example with
transfer_stratos
, the addition of a newtransfer_stratos
field saying to transfer is signed by the account, giving it authority, right? I just want to know if there is authorization to manage data. Like a database, there are access permissions. Fields in custom JSON have the account of whoever added that field I assume. So when an app adds data to custom JSON, it can do so on it's own account, or as a user ont he app that has authorized it to do so, for example with SteemConnect scope. Is this accurate?I'll check out the thread. Thanks for taking the time!
Yes, the transfer is signed by the account’s posting key. And yes, also apps can sign custom_json transactions on behalf of users.
Thanks. Is there a guide somewhere on how to do custom JSON? With dsteem or another library? I'll try to google search for it at some point ;) Thanks again for the informative discussion!
The only way I know to access custom_json transactions is directly through blocks — I’ve written a library called steem-state (and helper library steem-transact) that uses dsteem to make it easier to make custom_json DApps. There’s 3 tutorials, the first of them being in the README at https://github.com/nicholas-2/steem-state
By the end of the 3 tutorials you’ll have a fully functioning custom_json token!
Sweet! Thanks again!