<p>It's been done. It's lame. It's spam. You're incurring cost on the whole network for perpetuity (and no, the fee doesn't pay for that). </p>

<p>If you really can't stop yourself look at OP_RETURN as that's at least a much more network friendly way of doing it.</p>

CC BY-SA 3.0
2015-09-08T03:15:32.830Z
2015-09-08T03:15:32.830Z
Jannes
<p>You could use the <code>OP_RETURN</code> operation in your pubkey script. It gives you 80 bytes of free data (I think it is upgraded from 40 bytes recently you could check).</p>

<p>If you are a developer you could create a program based on bitcoinj which helps you to add an <code>OP_RETURN</code> operation to a transaction.</p>

<pre><code>Script script = new ScriptBuilder().op(ScriptOpCodes.OP_RETURN).data("your message".getBytes()).build();
                tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, script);
</code></pre>

<p>you could also look at these solutions :</p>

<ul>
<li><p><a href="https://github.com/coinspark/python-OP_RETURN" rel="nofollow">python OP_RETURN</a></p></li>
<li><p><a href="https://github.com/coinspark/php-OP_RETURN" rel="nofollow">php-OP_RETURN</a></p></li>
</ul>

CC BY-SA 3.0
2016-02-05T00:34:58.310Z
2016-02-07T15:03:12.777Z
2016-02-07T15:03:12.777Z
Badr Bellaj
<p>Bitcoin is for transactions, not storage. A bitcoin-derived system like Ethereum can be used to implement this. StorJ or FileCoin are special blockchain-like systems just for storage. </p>

CC BY-SA 3.0
2016-02-04T20:30:30.597Z
2016-02-04T20:30:30.597Z
Max
<blockquote>
  <p>Is this technique a good practice?</p>
</blockquote>

<p>NO!</p>

<blockquote>
  <p>Is there any other technique of doing this?</p>
</blockquote>

<p>Yes, there is a number of ways.</p>

<p><a href="http://www.righto.com/2014/02/ascii-bernanke-wikileaks-photographs.html" rel="nofollow">http://www.righto.com/2014/02/ascii-bernanke-wikileaks-photographs.html</a></p>

<p><a href="https://bitcointalk.org/index.php?topic=1023190.0" rel="nofollow">https://bitcointalk.org/index.php?topic=1023190.0</a></p>

<p><a href="https://github.com/petertodd/python-bitcoinlib/blob/master/examples/publish-text.py" rel="nofollow">https://github.com/petertodd/python-bitcoinlib/blob/master/examples/publish-text.py</a></p>

CC BY-SA 3.0
2015-09-01T19:06:31.380Z
You should explain why you think the technique is bad practice. In particular, the ascii bernake used essentially the same technique as the asker, just with larger outputs.
Nick ODell
CC BY-SA 3.0
2015-09-01T19:00:28.853Z
2015-09-01T19:00:28.853Z
amaclin
<p>As far my knowledge, data can be stored in blockchain by deploying smart contracts,using solidity compiler. The data that we want to store can be stored in struct variables of the smart contract and in form of strings. Once the contract is deployed, a hash is generated. The <em>hash</em> is then stored in the blockchain in form of linked list structure,which is <em>interconnected</em> with other hashes.</p>

CC BY-SA 3.0
2017-07-26T16:37:26.207Z
2017-07-26T16:37:26.207Z
Abhirup Mukherjee
<blockquote>
  <p>then you have 25 letters in base58, and that's like 17 bytes.</p>
</blockquote>

<p>20, actually.</p>

<blockquote>
  <p>So, you have to pay like 0.0001 BTC for the transaction fee, and after that you can add data to that transaction at a price of 17bytes per 1 satoshi, by sending satoshis to many addresses that contains the whole data. Imagine if we could store data there forever,.. and communicate with the future...</p>
</blockquote>

<p>You're going to run into two problems with this: transaction fees and dust rules. Transaction fees mean that each transaction will cost you a couple of cents. Dust rules mean that transactions with outputs below a certain size will simply be dropped. The rationale behind this is that you're sending a transaction so small that the fee required to redeem it will be more than the money that you're sending.</p>

<p>In the longer term, the data you're sending is going to look identical to all of the other data that's in the blockchain. That means that you need to identify your transaction somehow. That's usually done by providing the txid, which is 32 bytes.</p>

<blockquote>
  <p>Is this technique a good practice?</p>
</blockquote>

<p>It depends on what you're trying to accomplish. For example, are you trying to communicate anonymously? You should use BitMessage via Tor instead. Do you want to embed transactional data, like Counterparty does? Embedding the data in Bitcoin is probably the best solution for that.</p>

<blockquote>
  <p>... and communicate with the future...</p>
</blockquote>

<p>Well, the Internet Archive crawls all webpages (including this one!) so you're already uploading the things you've typed into a distributed, long-lasting datastore.</p>

CC BY-SA 3.0
2015-09-02T03:20:57.980Z
Thank you for the answer. How do you calculate that it's exactly 20 bytes? I am sure it must be very easy but I can't think of it.
Nathan Parker
CC BY-SA 3.0
2015-09-02T03:53:42.257Z
@NathanParker I didn't calculate it. Pay to Public Key Hash outputs have a 20-byte HASH160 hash, and that's what the main part of an address encodes.
Nick ODell
CC BY-SA 3.0
2015-09-02T13:51:38.860Z
So, an address is the hash of a public key? Then how do you know the public key given the address? How can you know a transaction was signed using his priv key if you don't know the public to compare? The only way I think of doing this would be by adding the public key in the transaction data.. ?
Nathan Parker
CC BY-SA 3.0
2015-09-02T17:18:22.937Z
They reveal the pubkey when spending it.
Nick ODell
CC BY-SA 3.0
2015-12-22T17:18:44.207Z
I forgot to thank you for this. So, thank you very much :)
Nathan Parker
CC BY-SA 3.0
2017-03-27T21:00:35.700Z
No. When SE is gone, some domain squatter will upload a robots.txt, which archive.org applies retroactively without questioning its authenticity, and this conversation will be gone.
Krumelur
CC BY-SA 3.0
2015-09-01T19:20:46.223Z
2015-09-01T19:20:46.223Z
Nick ODell
<p>I am wondering if it is possible to give someone a bitcoin transaction ID and with that he can read some hidden data, like the blockchain.info notes on transactions, but for real, stored in the blockchain forever.</p>

<p>I had this idea but I don't think if it would be a good practice:</p>

<p>Send the minimum amount of BTC possible, wich is <code>0.00000001 BTC</code>, or <code>1 satoshi</code>, to an address, and in that address would be the data.</p>

<p><strong>1</strong> ArFAXhvMbwJuub4ujnVbLFszqX3Mc<strong>uzsX</strong></p>

<p>As far as I know, the address is formed by 30 letters in base58, but since the first char must be <strong>1</strong> and the last four have to be the checksum, then you have 25 letters in base58, and that's like 17 bytes.</p>

<p>So, you have to pay like <code>0.0001 BTC</code> for the transaction fee, and after that you can add data to that transaction at a price of 17bytes per 1 satoshi, by sending satoshis to many addresses that contains the whole data. Imagine if we could store data there forever,.. and communicate with the future...</p>

<p>Is there any other technique of doing this? Is this technique a good practice?</p>

CC BY-SA 3.0
2016-02-07T17:37:34.237Z
Please don't encourage this misuse of the blockchain. There are altcoins for this purpose.
Jus12
CC BY-SA 3.0
2016-10-31T13:46:03.640Z
I'm even more confused now.  Reinsurance companies are starting to promote/investigate using the blockchain to store contracts/claims.  But the answers given here suggest its a dreadful idea.  What am I missing ?https://www2.deloitte.com/content/dam/Deloitte/uk/Documents/Innovation/deloitte-uk-blockchain-app-in-insurance.pdf
Mike Gledhill
CC BY-SA 3.0
2017-01-17T16:56:10.980Z
Jus12 - which altcoins are for this purpose?
frabcus
CC BY-SA 4.0
2021-01-10T10:17:52.563Z
Related: https://bitcoin.stackexchange.com/questions/32575/what-methods-are-currently-used-to-embed-additional-data-into-the-bitcoin-blockc
Ciro Santilli OurBigBook.com
<blockchain><bitcoind><network><raw-data>
How to store data on the blockchain?
Nathan Parker
# How to store data on the blockchain?

(Asked by: username_0 on 2015-09-01)

I am wondering if it is possible to give someone a bitcoin transaction ID and with that he can read some hidden data, like the blockchain.info notes on transactions, but for real, stored in the blockchain forever.

I had this idea but I don't think if it would be a good practice:

Send the minimum amount of BTC possible, wich is `0.00000001 BTC`, or `1 satoshi`, to an address, and in that address would be the data.

**1** ArFAXhvMbwJuub4ujnVbLFszqX3Mc**uzsX**

As far as I know, the address is formed by 30 letters in base58, but since the first char must be **1** and the last four have to be the checksum, then you have 25 letters in base58, and that's like 17 bytes.

So, you have to pay like `0.0001 BTC` for the transaction fee, and after that you can add data to that transaction at a price of 17bytes per 1 satoshi, by sending satoshis to many addresses that contains the whole data. Imagine if we could store data there forever,.. and communicate with the future...

Is there any other technique of doing this? Is this technique a good practice?

**Tags:** blockchain, bitcoind, network, raw-data

> **Comments:**
> **username_1**: Please don't encourage this misuse of the blockchain. There are altcoins for this purpose.  
> **username_2**: I'm even more confused now.  Reinsurance companies are starting to promote/investigate using the blockchain to store contracts/claims.  But the answers given here suggest its a dreadful idea.  What am I missing ?https://www2.deloitte.com/content/dam/Deloitte/uk/Documents/Innovation/deloitte-uk-blockchain-app-in-insurance.pdf  
> **username_3**: username_1 - which altcoins are for this purpose?  
> **username_4**: Related: https://bitcoin.stackexchange.com/questions/32575/what-methods-are-currently-used-to-embed-additional-data-into-the-bitcoin-blockc  

---

## 6 answers

### Answer by username_9 on 2015-09-01. Score: 8 | Accepted answer

> then you have 25 letters in base58, and that's like 17 bytes.

20, actually.

> So, you have to pay like 0.0001 BTC for the transaction fee, and after that you can add data to that transaction at a price of 17bytes per 1 satoshi, by sending satoshis to many addresses that contains the whole data. Imagine if we could store data there forever,.. and communicate with the future...

You're going to run into two problems with this: transaction fees and dust rules. Transaction fees mean that each transaction will cost you a couple of cents. Dust rules mean that transactions with outputs below a certain size will simply be dropped. The rationale behind this is that you're sending a transaction so small that the fee required to redeem it will be more than the money that you're sending.

In the longer term, the data you're sending is going to look identical to all of the other data that's in the blockchain. That means that you need to identify your transaction somehow. That's usually done by providing the txid, which is 32 bytes.

> Is this technique a good practice?

It depends on what you're trying to accomplish. For example, are you trying to communicate anonymously? You should use BitMessage via Tor instead. Do you want to embed transactional data, like Counterparty does? Embedding the data in Bitcoin is probably the best solution for that.

> ... and communicate with the future...

Well, the Internet Archive crawls all webpages (including this one!) so you're already uploading the things you've typed into a distributed, long-lasting datastore.

> **Comments:**
> **username_0**: Thank you for the answer. How do you calculate that it's exactly 20 bytes? I am sure it must be very easy but I can't think of it.  
> **username_9**: @username_0 I didn't calculate it. Pay to Public Key Hash outputs have a 20-byte HASH160 hash, and that's what the main part of an address encodes.  
> **username_0**: So, an address is the hash of a public key? Then how do you know the public key given the address? How can you know a transaction was signed using his priv key if you don't know the public to compare? The only way I think of doing this would be by adding the public key in the transaction data.. ?  
> **username_9**: They reveal the pubkey when spending it.  
> **username_0**: I forgot to thank you for this. So, thank you very much :)  
> **username_11**: No. When SE is gone, some domain squatter will upload a robots.txt, which archive.org applies retroactively without questioning its authenticity, and this conversation will be gone.  

---

### Answer by username_5 on 2015-09-08. Score: 5

It's been done. It's lame. It's spam. You're incurring cost on the whole network for perpetuity (and no, the fee doesn't pay for that).

If you really can't stop yourself look at OP\_RETURN as that's at least a much more network friendly way of doing it.


---

### Answer by username_6 on 2016-02-05. Score: 4

You could use the `OP_RETURN` operation in your pubkey script. It gives you 80 bytes of free data (I think it is upgraded from 40 bytes recently you could check).

If you are a developer you could create a program based on bitcoinj which helps you to add an `OP_RETURN` operation to a transaction.

```
Script script = new ScriptBuilder().op(ScriptOpCodes.OP_RETURN).data("your message".getBytes()).build();
                tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, script);

```

you could also look at these solutions :

* [python OP\_RETURN](https://github.com/coinspark/python-OP_RETURN)
* [php-OP\_RETURN](https://github.com/coinspark/php-OP_RETURN)


---

### Answer by username_7 on 2016-02-04. Score: 3

Bitcoin is for transactions, not storage. A bitcoin-derived system like Ethereum can be used to implement this. StorJ or FileCoin are special blockchain-like systems just for storage.


---

### Answer by username_8 on 2015-09-01. Score: 0

> Is this technique a good practice?

NO!

> Is there any other technique of doing this?

Yes, there is a number of ways.

<http://www.righto.com/2014/02/ascii-bernanke-wikileaks-photographs.html>

<https://bitcointalk.org/index.php?topic=1023190.0>

<https://github.com/petertodd/python-bitcoinlib/blob/master/examples/publish-text.py>

> **Comments:**
> **username_9**: You should explain why you think the technique is bad practice. In particular, the ascii bernake used essentially the same technique as the asker, just with larger outputs.  

---

### Answer by username_10 on 2017-07-26. Score: -4

As far my knowledge, data can be stored in blockchain by deploying smart contracts,using solidity compiler. The data that we want to store can be stored in struct variables of the smart contract and in form of strings. Once the contract is deployed, a hash is generated. The *hash* is then stored in the blockchain in form of linked list structure,which is *interconnected* with other hashes.


---

