<p>Dan Kaminsky explained his method and motivations for inserting images into the blockchain at a talk at Black Hat USA 2011 - the relevant slides (12 -20) from the presentation can be found <a href="http://www.slideshare.net/dakami/black-ops-of-tcpip-2011-black-hat-usa-2011" rel="nofollow">here.</a> </p>

<p>His basic method was to create transactions with lots of outputs and to include the message in ASCII, in pieces, in the receiving address field of the output scripts. You can see the corresponding hex codes for the ASCII in his message in the <a href="http://blockexplorer.com/rawtx/930a2114cdaa86e1fac46d15c74e81c09eee1d4150ff9d48e76cb0697d8e1d72" rel="nofollow">raw transaction</a>. You can see that the message is interrupted by the other transaction fields, so you can only see the messages properly if you look with a tool (such as <a href="http://linux.die.net/man/1/strings" rel="nofollow">strings</a>) that filters out non-printable characters and displays printable characters in lines. His transaction required a .15 bitcoin fee, about $1.50 at the time.</p>

CC BY-SA 3.0
2011-09-03T04:30:58.057Z
yes a slight explanation of the method used would be great.
lemonginger
CC BY-SA 3.0
2011-09-02T06:53:59.070Z
Can you provide a little bit of info in the answer besides the link?
ripper234
CC BY-SA 3.0
2011-09-01T23:42:39.653Z
2011-09-09T08:16:01.423Z
2011-09-09T08:16:01.423Z
kirian
<p>There was <a href="http://dankaminsky.com/2011/08/05/bo2k11/" rel="nofollow">a very interesting talk</a> at Chaos Communication Camp this year on this topic. IIRC, you can store arbitrary information in bitcoin transactions, since they actually contain "programs" specifying how the transaction should be verified.</p>

<p>Information on the 'scripting' interface can be found <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow">here</a>.  See section 2.3 for details on imbedding messages.</p>

CC BY-SA 3.0
2011-08-31T01:02:20.933Z
The question is about embedding data in block headers, not about transactions.
nmat
CC BY-SA 3.0
2011-08-31T10:22:05.003Z
@nmat: Well, if you're going to take it literally, then the answer is that you can't. At least, not by any means that are remotely practical. (The header is too small and most of the fields are compelled.)
David Schwartz
CC BY-SA 3.0
2011-08-30T21:26:43.510Z
2011-08-31T01:46:50.770Z
2011-08-31T01:46:50.770Z
Mononofu
<p>The hacker was <a href="http://en.wikipedia.org/wiki/Dan_Kaminsky" rel="nofollow">Dan Kaminsky</a>, and he embedded <a href="http://pastebin.com/raw.php?i=BUB3dygQ" rel="nofollow">this image</a> in the blockchain.</p>

<p>This is right now just a technological curiosity, it has no known implication on the legal or technical aspects of Bitcoin. I haven't read his paper, but he must have used a modified miner that searches for hashes that begin with a preset prefix.</p>

<p>Let's clarify: Mining is the process of finding solutions (or hashes) to a cryptography equation. The first to find a solution gets to have his solution added to the blockchain - the permanent transaction record. What Kaminsky did was look for a particular kind of hash instead of just any random hash, that contains the embedded test. Once this was found (just a matter of running a miner for a long enough period), this specific solution, with the embedded text, was added to the blockchain.</p>

CC BY-SA 3.0
2011-08-30T23:49:22.027Z
can you write a sentence or two about what that means (ie; how does one embed an image in a list of transactions). trying to get an answer here that shows no one had access to the blockchain to "change transaction data" or something similar.
lemonginger
CC BY-SA 3.0
2011-08-30T23:55:05.940Z
@lemoginger - does my extended answer answer your question?
ripper234
CC BY-SA 3.0
2011-08-31T00:02:59.003Z
I think so. I actually didn't understand how that worked myself :)
lemonginger
CC BY-SA 3.0
2011-08-31T00:40:28.830Z
Are you sure about this? According to [this](https://bitcointalk.org/index.php?topic=33618.msg420597#msg420597) he did it using transactions with special destination addresses
nmat
CC BY-SA 3.0
2011-08-31T00:43:08.267Z
@nmat - not sure at all, I had assumed this was how it was done. (Mother of all ****ups). Please post another answer.
ripper234
CC BY-SA 3.0
2011-09-01T22:40:16.883Z
yes someone please post another answer, this is definitely incorrect.
lemonginger
CC BY-SA 3.0
2011-08-30T23:46:17.250Z
2011-08-30T23:54:35.287Z
2011-08-30T23:54:35.287Z
ripper234
<p>When you generate a block, the generation transaction (the one that creates new coins) has an attribute called <strong>coinbase</strong>. It's a special value you can put anything you want in to make the block unpredictable to others (and this is good).</p>

<p>So, naturally, you can put text in this attribute, although most just put mining-related information that is not human-readable (nonce and extra-nonce).</p>

<p>You can read this coinbase by using a patched bitcoin node that can dump blocks, for example with the "dumpblock" or "getblockbyhash" patches.</p>

<p>Or you can just print every string in the blockchain database directly :
<code>strings -n 20 blk0001.dat</code></p>

<p>Example for the 1st block:</p>

<p>Coinbase: <code>04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73</code></p>

<p>ASCII-translation:
<code>ᝣᝣᝣᝣᝣᝣᝣEThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks</code></p>

<p>This is what is used by the Eligius pool ; it puts prayers in this field.</p>

CC BY-SA 3.0
2012-02-17T19:38:53.623Z
That http://pident.artefact2.com/b/0 link is dead.  It tells me "[...] is no longer available on this server and there is no forwarding address. Please remove all references to this resource."
Chris Moore
CC BY-SA 3.0
2011-08-30T21:30:30.133Z
Actually, that's not the most efficient way to store information in the blockchain. See my comment.
Mononofu
CC BY-SA 3.0
2011-08-30T21:34:08.943Z
True, it may not be the most efficient way, but it definitely is the easiest way (both for putting messages and reading them).
Artefact2
CC BY-SA 3.0
2011-08-30T21:28:38.357Z
2012-02-17T23:43:31.647Z
2012-02-17T23:43:31.647Z
Artefact2
<p>Some mining pool admins put custom data in block headers, <a href="https://bitcointalk.org/index.php?topic=38007.0">like prayers</a>. How do they do that? Where can I see that data for myself?</p>

CC BY-SA 3.0
2011-09-14T22:54:25.797Z
fair enough, can we now get one high-level answer that clarifies there are (at least) two ways that people have put messages and other custom data into the block chain?
lemonginger
CC BY-SA 3.0
2011-10-25T14:13:24.510Z
You can't embed ANYTHING in the block header. You can embed data in the block itself. The two methods are via the coinbase transaction or via a "dummy transaction". Neither of which put anything in the block header.
DeathAndTaxes
CC BY-SA 3.0
2012-02-12T07:00:40.817Z
People have written messages in the blockchain using http://etchablock.com/ - see http://blockexplorer.com/tx/237b50dac42af130171773b233954e62690182fd4901a453ad5d11d1d54a8ca3 for an example.
Chris Moore
<mining-pools><coinbase-transaction><block-header><mining-theory>
How can one embed custom data in block headers?
herzmeister
# How can one embed custom data in block headers?

(Asked by: username_0 on 2011-08-30)

Some mining pool admins put custom data in block headers, [like prayers](https://bitcointalk.org/index.php?topic=38007.0). How do they do that? Where can I see that data for myself?

**Tags:** mining-pools, coinbase-transaction, block-header, mining-theory

> **Comments:**
> **username_1**: fair enough, can we now get one high-level answer that clarifies there are (at least) two ways that people have put messages and other custom data into the block chain?  
> **username_2**: You can't embed ANYTHING in the block header. You can embed data in the block itself. The two methods are via the coinbase transaction or via a "dummy transaction". Neither of which put anything in the block header.  
> **username_3**: People have written messages in the blockchain using http://etchablock.com/ - see http://blockexplorer.com/tx/237b50dac42af130171773b233954e62690182fd4901a453ad5d11d1d54a8ca3 for an example.  

---

## 4 answers

### Answer by username_9 on 2011-08-30. Score: 18 | Accepted answer

When you generate a block, the generation transaction (the one that creates new coins) has an attribute called **coinbase**. It's a special value you can put anything you want in to make the block unpredictable to others (and this is good).

So, naturally, you can put text in this attribute, although most just put mining-related information that is not human-readable (nonce and extra-nonce).

You can read this coinbase by using a patched bitcoin node that can dump blocks, for example with the "dumpblock" or "getblockbyhash" patches.

Or you can just print every string in the blockchain database directly :
`strings -n 20 blk0001.dat`

Example for the 1st block:

Coinbase: `04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73`

ASCII-translation:
`ᝣᝣᝣᝣᝣᝣᝣEThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks`

This is what is used by the Eligius pool ; it puts prayers in this field.

> **Comments:**
> **username_6**: Actually, that's not the most efficient way to store information in the blockchain. See my comment.  
> **username_9**: True, it may not be the most efficient way, but it definitely is the easiest way (both for putting messages and reading them).  
> **username_3**: That http://pident.username_9.com/b/0 link is dead.  It tells me "[...] is no longer available on this server and there is no forwarding address. Please remove all references to this resource."  

---

### Answer by username_4 on 2011-09-01. Score: 7

Dan Kaminsky explained his method and motivations for inserting images into the blockchain at a talk at Black Hat USA 2011 - the relevant slides (12 -20) from the presentation can be found [here.](http://www.slideshare.net/dakami/black-ops-of-tcpip-2011-black-hat-usa-2011)

His basic method was to create transactions with lots of outputs and to include the message in ASCII, in pieces, in the receiving address field of the output scripts. You can see the corresponding hex codes for the ASCII in his message in the [raw transaction](http://blockexplorer.com/rawtx/930a2114cdaa86e1fac46d15c74e81c09eee1d4150ff9d48e76cb0697d8e1d72). You can see that the message is interrupted by the other transaction fields, so you can only see the messages properly if you look with a tool (such as [strings](http://linux.die.net/man/1/strings)) that filters out non-printable characters and displays printable characters in lines. His transaction required a .15 bitcoin fee, about $1.50 at the time.

> **Comments:**
> **username_5**: Can you provide a little bit of info in the answer besides the link?  
> **username_1**: yes a slight explanation of the method used would be great.  

---

### Answer by username_6 on 2011-08-30. Score: 5

There was [a very interesting talk](http://dankaminsky.com/2011/08/05/bo2k11/) at Chaos Communication Camp this year on this topic. IIRC, you can store arbitrary information in bitcoin transactions, since they actually contain "programs" specifying how the transaction should be verified.

Information on the 'scripting' interface can be found [here](https://en.bitcoin.it/wiki/Script). See section 2.3 for details on imbedding messages.

> **Comments:**
> **username_7**: The question is about embedding data in block headers, not about transactions.  
> **username_8**: @username_7: Well, if you're going to take it literally, then the answer is that you can't. At least, not by any means that are remotely practical. (The header is too small and most of the fields are compelled.)  

---

### Answer by username_5 on 2011-08-30. Score: -2

The hacker was [Dan Kaminsky](http://en.wikipedia.org/wiki/Dan_Kaminsky), and he embedded [this image](http://pastebin.com/raw.php?i=BUB3dygQ) in the blockchain.

This is right now just a technological curiosity, it has no known implication on the legal or technical aspects of Bitcoin. I haven't read his paper, but he must have used a modified miner that searches for hashes that begin with a preset prefix.

Let's clarify: Mining is the process of finding solutions (or hashes) to a cryptography equation. The first to find a solution gets to have his solution added to the blockchain - the permanent transaction record. What Kaminsky did was look for a particular kind of hash instead of just any random hash, that contains the embedded test. Once this was found (just a matter of running a miner for a long enough period), this specific solution, with the embedded text, was added to the blockchain.

> **Comments:**
> **username_1**: can you write a sentence or two about what that means (ie; how does one embed an image in a list of transactions). trying to get an answer here that shows no one had access to the blockchain to "change transaction data" or something similar.  
> **username_5**: @lemoginger - does my extended answer answer your question?  
> **username_1**: I think so. I actually didn't understand how that worked myself :)  
> **username_7**: Are you sure about this? According to [this](https://bitcointalk.org/index.php?topic=33618.msg420597#msg420597) he did it using transactions with special destination addresses  
> **username_5**: @username_7 - not sure at all, I had assumed this was how it was done. (Mother of all ****ups). Please post another answer.  
> **username_1**: yes someone please post another answer, this is definitely incorrect.  

---

