<p>From <a href="https://en.bitcoin.it/wiki/Protocol_documentation#Transaction_Verification" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Protocol_documentation#Transaction_Verification</a> we learn :</p>
<blockquote>
<p>Almost all integers are encoded in little endian. Only IP or port number are encoded big endian.</p>
</blockquote>
<p>You should look at the <a href="https://en.m.wikipedia.org/wiki/Endianness" rel="nofollow noreferrer">https://en.m.wikipedia.org/wiki/Endianness</a> and flip the order of the bitstring to have the bit at the correct position</p>
<p>Using an online hex converter like this one
<a href="https://www.scadacore.com/tools/programming-calculators/online-hex-converter/" rel="nofollow noreferrer">https://www.scadacore.com/tools/programming-calculators/online-hex-converter/</a> you can actually see that the hex interpreted as <code>uint32</code> results to <code>1</code></p>
<p><img src="https://i.sstatic.net/3tE92.jpg" alt="enter image description here" /></p>

CC BY-SA 4.0
2021-04-03T05:41:57.780Z
You gave me the information that I need to change the order of the chars in the hexstring from "01234567" to "67452301". That was very helpful. Thank you 
Martin Thoma
CC BY-SA 4.0
2021-04-02T11:55:17.020Z
2021-04-02T12:00:46.860Z
2021-04-02T12:00:46.860Z
Rene Pickhardt
<p>I am currently looking into the structure of bitcoin transactions. As an example, I took the hex dump of <a href="https://blockchain.info/tx/30713d08afa548d3465e380d6e1837354b29a1b6707e2a913b27776cf305fda4?format=hex" rel="nofollow noreferrer">this transaction</a>:</p>
<pre><code>010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5403df550a1b4d696e656420627920416e74506f6f6c373138fd004702c13ba070fabe6d6d6d9986fd3aedb9f8b00fab3c74c2e1d399fd0e6bc1d964aa57a08f78ac2d648002000000000000001eb50000c1377c00ffffffff04653c3a2a000000001976a91411dbe48cc6b617f9c6adaf4d9ed5f625b1c7cb5988ac0000000000000000266a24aa21a9ede0721e21cc17367eb4fcccf94c7e6ebc54757a693515f809307d4d6a31e0c8500000000000000000266a24b9e11b6d6eab9aaf2ccdc3cb05fb15989c512b84c8ef5f498559cd4d66e6104de8f9cdb100000000000000002b6a2952534b424c4f434b3a93320d7a461a95b953bd18e40aa031b5470d6258ccd82011999a5b290031529c0120000000000000000000000000000000000000000000000000000000000000000000000000
</code></pre>
<p>Looking at the <a href="https://blockchain.info/tx/30713d08afa548d3465e380d6e1837354b29a1b6707e2a913b27776cf305fda4?format=json" rel="nofollow noreferrer">JSON format</a>, the transaction version should be <code>1</code>.</p>
<p>I've read that the first 4 bytes of a transaction encode the version number (<a href="https://en.bitcoin.it/wiki/Transaction" rel="nofollow noreferrer">source</a>).</p>
<p>2 hex characters are one byte, so 4 bytes are 8 hex characters. So the version is <code>01000000</code>. But that would be <code>16777216</code>, not <code>1</code>.</p>
<p>What am I doing wrong?</p>

<transactions>
How can I get the transaction version from a hex dump?
Martin Thoma
# How can I get the transaction version from a hex dump?

(Asked by: username_0 on 2021-04-02)

I am currently looking into the structure of bitcoin transactions. As an example, I took the hex dump of this transaction:
010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5403df550a1b4d696e656420627920416e74506f6f6c373138fd004702c13ba070fabe6d6d6d9986fd3aedb9f8b00fab3c74c2e1d399fd0e6bc1d964aa57a08f78ac2d648002000000000000001eb50000c1377c00ffffffff04653c3a2a000000001976a91411dbe48cc6b617f9c6adaf4d9ed5f625b1c7cb5988ac0000000000000000266a24aa21a9ede0721e21cc17367eb4fcccf94c7e6ebc54757a693515f809307d4d6a31e0c8500000000000000000266a24b9e11b6d6eab9aaf2ccdc3cb05fb15989c512b84c8ef5f498559cd4d66e6104de8f9cdb100000000000000002b6a2952534b424c4f434b3a93320d7a461a95b953bd18e40aa031b5470d6258ccd82011999a5b290031529c0120000000000000000000000000000000000000000000000000000000000000000000000000

Looking at the JSON format, the transaction version should be 1.
I've read that the first 4 bytes of a transaction encode the version number (source).
2 hex characters are one byte, so 4 bytes are 8 hex characters. So the version is 01000000. But that would be 16777216, not 1.
What am I doing wrong?

**Tags:** transactions


---

## 1 answers

### Answer by username_1 on 2021-04-02. Score: 5 | Accepted answer

From <https://en.bitcoin.it/wiki/Protocol_documentation#Transaction_Verification> we learn :

> Almost all integers are encoded in little endian. Only IP or port number are encoded big endian.

You should look at the <https://en.m.wikipedia.org/wiki/Endianness> and flip the order of the bitstring to have the bit at the correct position

Using an online hex converter like this one
<https://www.scadacore.com/tools/programming-calculators/online-hex-converter/> you can actually see that the hex interpreted as `uint32` results to `1`

![enter image description here](https://i.sstatic.net/3tE92.jpg)

> **Comments:**
> **username_0**: You gave me the information that I need to change the order of the chars in the hexstring from "01234567" to "67452301". That was very helpful. Thank you   

---

