Bitcoin Forum

Bitcoin => Project Development => Topic started by: Patatas on June 01, 2019, 01:28:05 PM



Title: Data on Blockchain [Question]
Post by: Patatas on June 01, 2019, 01:28:05 PM
Just wondering how feasible it is to show data on the blockchain along with a transaction? Like a transaction with an item name? For instance, imagine I'm creating a smart contract using Ethereum and with every transaction I want the item name to persist in the blockchain. Is that even possible? This is not like naming an address or something but actual text data with a transaction that is visible on the block explorer.


Title: Re: Data on Blockchain [Question]
Post by: NeuroticFish on June 01, 2019, 08:08:30 PM
Just wondering how feasible it is to show data on the blockchain along with a transaction? Like a transaction with an item name? For instance, imagine I'm creating a smart contract using Ethereum and with every transaction I want the item name to persist in the blockchain. Is that even possible? This is not like naming an address or something but actual text data with a transaction that is visible on the block explorer.

I don't know on Ethereum, but you can easily add short texts into Bitcoin transaction.
It may not be pretty, but it can be done and seen. One example is (see the last decoded part in OP_RETURN) https://chain.so/tx/BTC/27daac15b942454b32f913a41633151163d1921b0c7bf6ddbea6020462d805ee
Some explanations on the subject (for Bitcoin) are https://www.reddit.com/r/btc/comments/49pp3n/eli5_how_to_embed_text_into_a_bitcoin_transaction/

If you insist on doing this on Ethereum blockchain, maybe you should look here: https://cryptobulls.info/store-text-message-ethereum-blockchain-censorship-resistant
(it's one of the results from the search engine)


Title: Re: Data on Blockchain [Question]
Post by: elda34b on June 01, 2019, 10:14:11 PM
Theoretically, and in practice, you can already do that on various blockchains. It might not be pretty, and you might need to convert your data to other formats, just like what you need to do on Ethereum blockchain on tutorial linked above. AFAIK, some projects offer "anchoring" which basically stores/records a hash of a data, which is essentially the same as a text.

You might want to fork or create your own blockchain if you want a prettier look on how the data encoded/recorded.


Title: Re: Data on Blockchain [Question]
Post by: therealifiok on June 02, 2019, 03:42:09 AM
You might have to create your own blockchain


Title: Re: Data on Blockchain [Question]
Post by: pooya87 on June 03, 2019, 03:18:30 AM
actually you don't even need OP_Return if the option doesn't exist, you just have to view transactions differently. a transaction is jut a data structure with different parts that we interpret differently. for instance the first 4 bytes of a transaction is interpreted as a number which we call "version".

so in order to put "data" in a transaction you just have to find a field in your tx that allows you to enter data. in a transaction this can be the output. with OP_Return it becomes easier since it is designed for data but you can still do it with other OPs too. for instance the regular P2PKH outputs can be used (assuming OP_Return doesn't exist). you just have to change the pushed data to the value you like.

example: if you pay any amount to this address: 18L1ocUNq8EKJu1UHu92HKUk4jeXL9eXoL you are technically putting your bitcointalk username (Patatas) in the blockchain because if you look at the transaction's actual data you can see that this address is actually stored like this as an output:
76a914506174617461730000000000000000000000000088ac
or in more human readable format:
OP_DUP OP_HASH160 <Patatas(nullpaded)> OP_EQUALVERIFY OP_CHECKSIG

ps. obviously any amount sent to this address is lost because it is a burn address.


Title: Re: Data on Blockchain [Question]
Post by: Patatas on June 08, 2019, 01:13:33 PM
I don't know on Ethereum, but you can easily add short texts into Bitcoin transaction.
Yeah, I'm aware of that but that is not what I was looking for. Thanks for your inputs though.

actually you don't even need OP_Return if the option doesn't exist, you just have to view transactions differently. a transaction is jut a data structure with different parts that we interpret differently. for instance the first 4 bytes of a transaction is interpreted as a number which we call "version".

so in order to put "data" in a transaction you just have to find a field in your tx that allows you to enter data. in a transaction this can be the output. with OP_Return it becomes easier since it is designed for data but you can still do it with other OPs too. for instance the regular P2PKH outputs can be used (assuming OP_Return doesn't exist). you just have to change the pushed data to the value you like.

example: if you pay any amount to this address: 18L1ocUNq8EKJu1UHu92HKUk4jeXL9eXoL you are technically putting your bitcointalk username (Patatas) in the blockchain because if you look at the transaction's actual data you can see that this address is actually stored like this as an output:
76a914506174617461730000000000000000000000000088ac
or in more human readable format:
OP_DUP OP_HASH160 <Patatas(nullpaded)> OP_EQUALVERIFY OP_CHECKSIG

ps. obviously any amount sent to this address is lost because it is a burn address.
That is something I will consider. However, for every transaction say the transaction creator will be entering data. How hard it is to achieve this on a programming level and of course on ETH chain. Will the above scenario work for a smart contract as well?


Title: Re: Data on Blockchain [Question]
Post by: pooya87 on June 09, 2019, 01:56:28 AM
That is something I will consider. However, for every transaction say the transaction creator will be entering data. How hard it is to achieve this on a programming level and of course on ETH chain. Will the above scenario work for a smart contract as well?

it is very easy to code this since it is just a trivial and simple code to write as long as you have basic familiarity with transaction structure and scripts.
as for ethereum case, i am not that familiar with its blockchain but you should be able to find a way to construct a smart contract to do that too.