<p>I already answered this for you <a href="https://bitcoin.stackexchange.com/a/111634/51948">here</a></p>
<blockquote>
<p>The amount should be encoded as 8 bytes, in little-endian format. If you want to send 1 million satoshis, this would be 0x40420F0000000000.</p>
</blockquote>
<p>The zeroes are always written because the value must be 8 bytes long, least significant byte first. Note that this is in hexadecimal not decimal.</p>
<p>The miner fee is not written in the transaction. It is calculated by subtracting the total value of the outputs from the total value of the inputs. The difference is the fee.</p>

CC BY-SA 4.0
2022-01-06T19:15:33.163Z
2022-01-06T19:15:33.163Z
meshcollider
<p>Actually, the value of this transaction (<code>2621c2609d114f652dadf6fd95820c021da1cf2d0ac15e0361fd5d136e30a3c4</code>) is <code>255d020000000000</code>, with is an 8-byte little-endian version of 0.00154917 BTC. For interpreting it, you reverse all bytes. Ignoring all redundant zeroes, you get <code>0x025d25</code> with is the hex value for 154917 sats or 0.00154917 BTC.</p>
<p>This transaction, once parsed, looks like this:<br />
<code>01000000</code>: Version. Little-endian representation of 1<br />
<code>0x01</code>: Input count, one in this case<br />
<code>72f5d096ce8d2055d46db83cd969265f99146f09c30fd9c7b4e77e46830b6e7e00000000</code>:  Previous output, the first 64 digits are txid and the remaining 8, the index of a UTXO being spent.<br />
<code>0x6a</code>: Size of the scriptSig, 106 in this case<br />
<code>473044022033bff843a014d1958eeb6f6dda47879a6cdab139cb85a818905c8e4f034c4bed022028361e8e3f43df257f31cd6c502b155facf70256d230e5cd059a8b83ef864f360121027580575d62d199ea4560451402b035eeb9786972d2c1a2c17b6e798d97265dda</code>: A relly big scriptSig<br />
<code>0xffffffff</code>: nSequence<br />
<code>01</code>: Output count, just one<br />
<code>255d020000000000</code>: Value in sats and little-endian<br />
<code>0x19</code>: Size of the scriptPubkey<br />
<code>76a9145030f21fe34949ccacdd9505c50f223c5685f70588ac</code>: Spk<br />
<code>00000000</code>: nLockTime</p>
<p>Source: <a href="https://en.bitcoin.it/wiki/Protocol_documentation#tx" rel="nofollow noreferrer">bitcoinWiki</a></p>

CC BY-SA 4.0
2022-01-06T17:45:27.230Z
2022-01-06T17:45:27.230Z
Davidson Souza
<p>I am currently learning about bitcoin, and I came up to this:
<a href="https://medium.datadriveninvestor.com/bitcoin-raw-transaction-breakdown-c0a5a3aa8688" rel="nofollow noreferrer">https://medium.datadriveninvestor.com/bitcoin-raw-transaction-breakdown-c0a5a3aa8688</a> to know more about raw tx.</p>
<p>What I cannot understand is that, he is sending bitcoin 0.00156636 BTC = 156636 Sat, then why in raw tx the value is like: <code>60e3160000000000</code></p>
<p>And are those zeros at end always written?</p>
<p>How miner fee is written?</p>
<p>Link to blockchain.com regarding transaction detail: <a href="https://www.blockchain.com/btc/tx/2621c2609d114f652dadf6fd95820c021da1cf2d0ac15e0361fd5d136e30a3c4" rel="nofollow noreferrer">https://www.blockchain.com/btc/tx/2621c2609d114f652dadf6fd95820c021da1cf2d0ac15e0361fd5d136e30a3c4</a></p>

<raw-transaction>
How value of btc to be send is written in raw transaction?
madhurkant
# How value of btc to be send is written in raw transaction?

(Asked by: username_0 on 2022-01-06)

I am currently learning about bitcoin, and I came up to this:
<https://medium.datadriveninvestor.com/bitcoin-raw-transaction-breakdown-c0a5a3aa8688> to know more about raw tx.

What I cannot understand is that, he is sending bitcoin 0.00156636 BTC = 156636 Sat, then why in raw tx the value is like: `60e3160000000000`

And are those zeros at end always written?

How miner fee is written?

Link to blockchain.com regarding transaction detail: <https://www.blockchain.com/btc/tx/2621c2609d114f652dadf6fd95820c021da1cf2d0ac15e0361fd5d136e30a3c4>

**Tags:** raw-transaction


---

## 2 answers

### Answer by username_1 on 2022-01-06. Score: 2

I already answered this for you [here](https://bitcoin.stackexchange.com/a/111634/51948)

> The amount should be encoded as 8 bytes, in little-endian format. If you want to send 1 million satoshis, this would be 0x40420F0000000000.

The zeroes are always written because the value must be 8 bytes long, least significant byte first. Note that this is in hexadecimal not decimal.

The miner fee is not written in the transaction. It is calculated by subtracting the total value of the outputs from the total value of the inputs. The difference is the fee.


---

### Answer by username_2 on 2022-01-06. Score: 1

Actually, the value of this transaction (`2621c2609d114f652dadf6fd95820c021da1cf2d0ac15e0361fd5d136e30a3c4`) is `255d020000000000`, with is an 8-byte little-endian version of 0.00154917 BTC. For interpreting it, you reverse all bytes. Ignoring all redundant zeroes, you get `0x025d25` with is the hex value for 154917 sats or 0.00154917 BTC.

This transaction, once parsed, looks like this:  
`01000000`: Version. Little-endian representation of 1  
`0x01`: Input count, one in this case  
`72f5d096ce8d2055d46db83cd969265f99146f09c30fd9c7b4e77e46830b6e7e00000000`: Previous output, the first 64 digits are txid and the remaining 8, the index of a UTXO being spent.  
`0x6a`: Size of the scriptSig, 106 in this case  
`473044022033bff843a014d1958eeb6f6dda47879a6cdab139cb85a818905c8e4f034c4bed022028361e8e3f43df257f31cd6c502b155facf70256d230e5cd059a8b83ef864f360121027580575d62d199ea4560451402b035eeb9786972d2c1a2c17b6e798d97265dda`: A relly big scriptSig  
`0xffffffff`: nSequence  
`01`: Output count, just one  
`255d020000000000`: Value in sats and little-endian  
`0x19`: Size of the scriptPubkey  
`76a9145030f21fe34949ccacdd9505c50f223c5685f70588ac`: Spk  
`00000000`: nLockTime

Source: [bitcoinWiki](https://en.bitcoin.it/wiki/Protocol_documentation#tx)


---

