<p>What you are looking at is the length of a string of hexadecimal characters. When representing data has a hex string, one byte is represented with two characters.  However the software does not store the block or transaction data as a hex string, it just stores it as an array of bytes which is later represented as a hex string with each byte having 2 characters. So when the software gets the size of the transaction, it just gets the number of bytes stored in the array, and since each byte corresponds to 2 characters in hexadecimal, when you get the hex string, the hex string will be twice as long as the number of bytes that the block or transaction actually is.</p>

CC BY-SA 3.0
2017-07-07T06:07:16.693Z
2017-07-07T06:07:16.693Z
Ava Chow
<p>One byte is 8 bits and one hexadecimal digit is representing 4 bits, therefore byte lenght is half the lenght of the hex stream. <em>Transaction length</em> is the byte length.</p>

CC BY-SA 3.0
2017-08-06T09:02:26.590Z
2017-08-06T09:02:26.590Z
Hubert Jasieniecki
<p>Each byte is 8 bits - so in order to display a single byte in hexadecimal, we must see two characters.  However when you get the length of a string, you are getting the number of bytes in the string, not its hex equivalent - understand?  Therefore it is not necessary to divide by two.  If you convert a string into hex, then yes - the hex string will be twice the size, but that is not what you want.</p>

CC BY-SA 3.0
2014-01-01T04:27:35.703Z
2014-01-01T04:27:35.703Z
John Lowe
<p>I was looking over the <a href="https://en.bitcoin.it/wiki/Abe" rel="nofollow">Abe</a> code once again, and came to a stumbling point. I can't understand how this is accurate:</p>

<pre><code>tx['size'] = len(tx['tx'])
</code></pre>

<p>Transaction size is simply the length of the raw transaction string? I did not think that 1 character of that string was equal to one byte. </p>

<p>Edit: while tinkering around with this with a simple python command line program, I was able to determine that the block size is actually half of the raw transaction string length. I also found out this: </p>

<p><a href="http://en.wikipedia.org/wiki/Hexadecimal" rel="nofollow">http://en.wikipedia.org/wiki/Hexadecimal</a></p>

<blockquote>
  <p>Each hexadecimal digit represents four binary digits (bits), and the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics. One hexadecimal digit represents a nibble, which is half of an octet or byte (8 bits).</p>
</blockquote>

<p>Though it still doesn't answer the question, why isn't the size divided by two in the ABE source code?</p>

CC BY-SA 3.0
2016-07-14T10:41:14.757Z
This answer in StackExchange might help: http://bitcoin.stackexchange.com/a/3011/38618
MCCCS
CC BY-SA 3.0
2016-09-10T00:11:46.880Z
As you said tx['tx'] is the "raw transaction string" and not it's hexadecimal representation. In this case 1 char does represent 1 byte
Dylan James McGannon
CC BY-SA 3.0
2017-06-07T05:05:53.310Z
You are confusing hexadecimal (which is not raw) with a raw string. For example, the raw string "X" can be represented by the hexadecimal string "58". There is no reason to halve the length of the raw transaction string.
David Schwartz
<transactions><blockchain><abe>
How does Abe or any blockchain explorer determine transaction size?
bvpx
# How does Abe or any blockchain explorer determine transaction size?

(Asked by: username_0 on 2013-07-26)

I was looking over the Abe code once again, and came to a stumbling point. I can't understand how this is accurate:
tx['size'] = len(tx['tx'])

Transaction size is simply the length of the raw transaction string? I did not think that 1 character of that string was equal to one byte. 
Edit: while tinkering around with this with a simple python command line program, I was able to determine that the block size is actually half of the raw transaction string length. I also found out this: 
http://en.wikipedia.org/wiki/Hexadecimal

Each hexadecimal digit represents four binary digits (bits), and the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics. One hexadecimal digit represents a nibble, which is half of an octet or byte (8 bits).

Though it still doesn't answer the question, why isn't the size divided by two in the ABE source code?

**Tags:** transactions, blockchain, abe

> **Comments:**
> **username_1**: This answer in StackExchange might help: http://bitcoin.stackexchange.com/a/3011/38618  
> **username_2**: As you said tx['tx'] is the "raw transaction string" and not it's hexadecimal representation. In this case 1 char does represent 1 byte  
> **username_3**: You are confusing hexadecimal (which is not raw) with a raw string. For example, the raw string "X" can be represented by the hexadecimal string "58". There is no reason to halve the length of the raw transaction string.  

---

## 3 answers

### Answer by username_4 on 2017-07-07. Score: 1

What you are looking at is the length of a string of hexadecimal characters. When representing data has a hex string, one byte is represented with two characters. However the software does not store the block or transaction data as a hex string, it just stores it as an array of bytes which is later represented as a hex string with each byte having 2 characters. So when the software gets the size of the transaction, it just gets the number of bytes stored in the array, and since each byte corresponds to 2 characters in hexadecimal, when you get the hex string, the hex string will be twice as long as the number of bytes that the block or transaction actually is.


---

### Answer by username_5 on 2017-08-06. Score: 0

One byte is 8 bits and one hexadecimal digit is representing 4 bits, therefore byte lenght is half the lenght of the hex stream. *Transaction length* is the byte length.


---

### Answer by username_6 on 2014-01-01. Score: 0

Each byte is 8 bits - so in order to display a single byte in hexadecimal, we must see two characters. However when you get the length of a string, you are getting the number of bytes in the string, not its hex equivalent - understand? Therefore it is not necessary to divide by two. If you convert a string into hex, then yes - the hex string will be twice the size, but that is not what you want.


---

