<blockquote>
  <p>Isnt it supposed to be 2. The above is a really large number in big endian.</p>
</blockquote>

<p>It's a small number in big endian. Think about it; <em>big</em> digits at the <em>end</em>.</p>

<blockquote>
  <p>Now the previuos hash block</p>
</blockquote>

<p>I don't know why Bitcoin does this, but block hashes are stored in normal order internally, then byte-reversed before displaying them. </p>

<pre><code>&gt;&gt;&gt; s="e965bfc2111c7a63a12b5c95ff9b5cc44f2d32ad9e52d9a04301000000000000"
&gt;&gt;&gt; import binascii
&gt;&gt;&gt; s=binascii.unhexlify(s)
&gt;&gt;&gt; s=s[::-1]
&gt;&gt;&gt; s=binascii.hexlify(s)
&gt;&gt;&gt; s
</code></pre>

<p>'<a href="https://blockchain.info/block-index/388514/0000000000000143a0d9529ead322d4fc45c9bff955c2ba1637a1c11c2bf65e9" rel="nofollow">0000000000000143a0d9529ead322d4fc45c9bff955c2ba1637a1c11c2bf65e9</a>'</p>

<blockquote>
  <p>Time:<br>
  a77ead51</p>
</blockquote>

<p>Use big endian. I got 1370324647 using <a href="http://www.darkfader.net/toolbox/convert/" rel="nofollow">this tool</a>, then converted to 04 Jun 2013 with <a href="http://www.epochconverter.com/" rel="nofollow">this tool.</a></p>

CC BY-SA 3.0
2013-06-05T01:43:26.657Z
I didnt know I have to do that extra step to get the data. Anyway I think I understand now. Thanks a lot. Just out of curiosity, how did you know this?
Enthusiast
CC BY-SA 3.0
2013-06-05T16:33:59.600Z
@Enthusiast Reading wiki articles, bitcoin source code, [pyminer source code](https://github.com/jgarzik/pyminer). Also, I started writing a mining client, but I lost interest.
Nick ODell
CC BY-SA 3.0
2013-06-04T16:09:22.253Z
2013-06-04T16:09:22.253Z
Nick ODell
<p>I called bitcoind getwork slightly earlier in the day and this is what I got:</p>

<pre><code>{
    "midstate" : "6d8b2d759123e7311c552f0c99f6d520378062ac7a14fb11f6d433779d282faf",
    "data" : "00000002c2bf65e9637a1c11955c2ba1c45c9bffad322d4fa0d9529e0000014300000000e9587c30863f5f410ea9d0611d3da6b7d0afd390b4b8e33cd71297c9d20dc74651ad7ea71a01616400000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
    "hash1" : "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000",
    "target" : "0000000000000000000000000000000000000000000000646101000000000000"
}
</code></pre>

<p>So for the time being lets throw away the midstate which I will not be using since I am only trying to understand.
So now doing the 32 bit byteswap on the data I get this:</p>

<pre><code>Data
02000000 e965bfc2111c7a63a12b5c95ff9b5cc4 4f2d32ad9e52d9a04301000000000000 307c58e9415f3f8661d0a90eb7a63d1d90d3afd03ce3b8b4c99712d746c70dd2 a77ead51 6461011a 00000000
</code></pre>

<p>Now I am unable to figure out how to actually read this information. According to the wiki, the first 4 bytes are version. Here the first 4 bytes are version. </p>

<pre><code>Version:
02000000
</code></pre>

<p>Isnt it supposed to be 2. The above is a really large number in big endian.</p>

<p>Now the previuos hash block:</p>

<pre><code>Hash:
e965bfc2111c7a63a12b5c95ff9b5cc44f2d32ad9e52d9a04301000000000000
</code></pre>

<p>I am unable to find this hash anywhere on blockexplorer or block chain info? I tried to change the endianess once again but to no avail.</p>

<p>Finally I left the merkle root out and tried to confirm with the utc time:</p>

<pre><code>Time:
a77ead51
</code></pre>

<p>Which corresponds to the year 2081. What exactly am I doing wrong here?</p>

CC BY-SA 3.0
2013-06-04T08:19:30.233Z
`getwork` has been pretty much deprecated, you should use `getblocktemplate` instead.
jgm
<getwork>
I am unable to figure the getwork api
Enthusiast
# I am unable to figure the getwork api

(Asked by: username_0 on 2013-06-04)

I called bitcoind getwork slightly earlier in the day and this is what I got:

```
{
    "midstate" : "6d8b2d759123e7311c552f0c99f6d520378062ac7a14fb11f6d433779d282faf",
    "data" : "00000002c2bf65e9637a1c11955c2ba1c45c9bffad322d4fa0d9529e0000014300000000e9587c30863f5f410ea9d0611d3da6b7d0afd390b4b8e33cd71297c9d20dc74651ad7ea71a01616400000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
    "hash1" : "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000",
    "target" : "0000000000000000000000000000000000000000000000646101000000000000"
}

```

So for the time being lets throw away the midstate which I will not be using since I am only trying to understand.
So now doing the 32 bit byteswap on the data I get this:

```
Data
02000000 e965bfc2111c7a63a12b5c95ff9b5cc4 4f2d32ad9e52d9a04301000000000000 307c58e9415f3f8661d0a90eb7a63d1d90d3afd03ce3b8b4c99712d746c70dd2 a77ead51 6461011a 00000000

```

Now I am unable to figure out how to actually read this information. According to the wiki, the first 4 bytes are version. Here the first 4 bytes are version.

```
Version:
02000000

```

Isnt it supposed to be 2. The above is a really large number in big endian.

Now the previuos hash block:

```
Hash:
e965bfc2111c7a63a12b5c95ff9b5cc44f2d32ad9e52d9a04301000000000000

```

I am unable to find this hash anywhere on blockexplorer or block chain info? I tried to change the endianess once again but to no avail.

Finally I left the merkle root out and tried to confirm with the utc time:

```
Time:
a77ead51

```

Which corresponds to the year 2081. What exactly am I doing wrong here?

**Tags:** getwork

> **Comments:**
> **username_1**: `getwork` has been pretty much deprecated, you should use `getblocktemplate` instead.  

---

## 1 answers

### Answer by username_2 on 2013-06-04. Score: 1 | Accepted answer

> Isnt it supposed to be 2. The above is a really large number in big endian.

It's a small number in big endian. Think about it; *big* digits at the *end*.

> Now the previuos hash block

I don't know why Bitcoin does this, but block hashes are stored in normal order internally, then byte-reversed before displaying them.

```
>>> s="e965bfc2111c7a63a12b5c95ff9b5cc44f2d32ad9e52d9a04301000000000000"
>>> import binascii
>>> s=binascii.unhexlify(s)
>>> s=s[::-1]
>>> s=binascii.hexlify(s)
>>> s

```

'[0000000000000143a0d9529ead322d4fc45c9bff955c2ba1637a1c11c2bf65e9](https://blockchain.info/block-index/388514/0000000000000143a0d9529ead322d4fc45c9bff955c2ba1637a1c11c2bf65e9)'

> Time:  
> a77ead51

Use big endian. I got 1370324647 using [this tool](http://www.darkfader.net/toolbox/convert/), then converted to 04 Jun 2013 with [this tool.](http://www.epochconverter.com/)

> **Comments:**
> **username_0**: I didnt know I have to do that extra step to get the data. Anyway I think I understand now. Thanks a lot. Just out of curiosity, how did you know this?  
> **username_2**: @username_0 Reading wiki articles, bitcoin source code, [pyminer source code](https://github.com/jgarzik/pyminer). Also, I started writing a mining client, but I lost interest.  

---

