Outputs: Amount

TransactionAmount
Structure
Version
4 bytes
Segwit (Optional)
Marker
1 byte
Flag
1 byte
Structure
Input Count
variable
Input Structure
Previous TXID
32 bytes
Output Index
4 bytes
ScriptSig Size
variable
ScriptSig
variable
Sequence
4 bytes
Structure
Output Count
variable
Output Structure
Amount
8 bytes
ScriptPubKey Size
variable
ScriptPubKey
variable
Structure
Witness
variable
Structure
Locktime
4 bytes

Size

8 bytes

Format

Little-Endian

Description

The value in satoshis to be transferred.

Example

e803000000000000

Byte Visualization

e8
Byte 1
03
Byte 2
00
Byte 3
00
Byte 4
00
Byte 5
00
Byte 6
00
Byte 7
00
Byte 8

The amount field in a transaction output specifies how many satoshis (the smallest unit of bitcoin) are being assigned to this output.

Let's examine our transaction to understand this better:

SVG Image

Amount Field Structure

  • Size: 8 bytes (64 bits)
  • Format: Little-endian integer
  • Unit: Satoshis (1 BTC = 100,000,000 satoshis)
  • Range: 0 to 21,000,000 * 100,000,000 satoshis (maximum bitcoin supply)

Note

The amount field uses 8 bytes because the maximum bitcoin supply (21 million BTC) in satoshis exceeds what could be stored in 4 bytes (maximum ~42.94967296 BTC).

Implementation Example

Here's how you might parse a transaction output's amount:

python
def parse_amount(raw_tx: bytes, offset: int = 0) -> tuple[int, int]:
    """
    Parse an amount from raw transaction bytes
    
    Args:
        raw_tx: Raw transaction bytes
        offset: Starting position in bytes
        
    Returns:
        (amount, new_offset)
    """
    # Read 8 bytes for amount
    amount_bytes = raw_tx[offset:offset + 8]
    
    # Convert to integer (little-endian)
    amount = int.from_bytes(amount_bytes, 'little')
    
    return amount, offset + 8

Amount Validation Rules

When validating transaction amounts, nodes must ensure:

  1. Non-negative: All output amounts must be ≥ 0 satoshis
  2. Input sum ≥ Output sum: The sum of all input amounts must be greater than or equal to the sum of all output amounts
  3. Maximum supply: No single output can exceed the maximum bitcoin supply (21 million BTC)

Warning

The difference between input and output amounts becomes the transaction fee, which is collected by miners. Be careful not to accidentally set high fees by miscalculating output amounts!

Unit Conversion

Here's a helpful function for converting between BTC and satoshis:

python
def btc_to_satoshis(btc: float) -> int:
    """Convert BTC amount to satoshis"""
    return int(btc * 100_000_000)

def satoshis_to_btc(sats: int) -> float:
"""Convert satoshi amount to BTC"""
return sats / 100_000_000

Common conversions:

  • 1 BTC = 100,000,000 satoshis
  • 0.00000001 BTC = 1 satoshi
  • 0.001 BTC = 100,000 satoshis

Historical Note

The term "satoshi" was adopted by the Bitcoin community to honor Bitcoin's creator, Satoshi Nakamoto. The small unit size allows for very precise value transfer and future-proofs Bitcoin against significant price appreciation.

Suggest Edits
View our public visitor count
Built with 🧡 by the Bitcoin Dev Project
We'd love to hear your feedback on this project?Give Feedback