Published to Dev.to — Bitcoin Development Series, Part 2 of 4

Ordinals are at the center of one of the most heated protocol debates in Bitcoin right now (see Part 1 on BIP-110). But most of the commentary stays at the application layer, NFTs, JPEG files on-chain, satoshi numbering. The actual mechanism is more interesting than the culture war around it. This post goes through exactly how data gets inscribed into a Bitcoin transaction, why it works within the existing rules, and how you can interact with it programmatically.

The Foundation: How Bitcoin Numbers Satoshis

The Ordinals protocol assigns a unique serial number to every satoshi, based purely on the order they were mined. The first satoshi of the first coinbase transaction is ordinal 0. The numbering increments across every output of every block in sequence, forever.

def ordinal_range_for_block(block_height: int, subsidy_sats: int) -> tuple[int, int]: