Rodamor’s Bitcoin Ordinals Explained

Keir Finlow-Bates
9 min readFeb 4, 2023

Although Casey Rodamor helpfully provides some Python code to explain Bitcoin Ordinals, not many people are going to understand how Ordinals work just by looking at a screenful of code.

In this article, I explain how each and every satoshi in Bitcoin has been given its own unique number, and hence identity, by Casey Rodamor.

What are ordinals?

To start with — what does “ordinal” mean? The Collins dictionary defines ordinal as “denoting a certain position in a sequence of numbers”. This allows us to talk about a first thing, and a second thing, and so on, in a list of things. A list of counting numbers can be ordered, and has a clear natural ordering — given two different numbers, everyone will agree which one comes first. Seven comes before eleven, for example.

But a list of fruit cannot be ordered. Does an orange come before an apple? If you decide to order fruit alphabetically, then in English the answer would be: no.

But in French that doesn’t work: orange comes before pomme alphabetically. Names of fruits are arbitrary inventions of language, and so there is no accepted global standard for ordering them.

I would argue that the ordering of satoshis defined by Rodamor may appear natural at first, but there are some edge cases that make it arbitrary. That doesn’t detract from his achievement, because if we all agree to use an arbitrary ordering as a standard, it becomes the de facto natural standard.

And Rodamor’s ordering is certainly a sensible and justifiable one.

Everything you need to know about satoshis

The next thing you need to understand is there is no such thing as “a bitcoin” in the Bitcoin code. The base unit of accounting is the satoshi, and we use the word “bitcoin” to refer to 100 million of them.

The way to understand this is to imagine a world in which there are no dollars, only pennies. We can still talk about dollars, and price things in dollars, but when it comes time to pay and you want to get that $1.50 can of soda, you have to hand over 150 pennies. Because a dollar is an imaginary grouping of pennies.

So from now on I won’t talk about bitcoin, I will only talk about satoshis. It’s the smallest unit of accounting that occurs on the chain (although I could agree to owe you a tenth of a satoshi every day, I wouldn’t be able to pay you until ten days had passed and the total debt was one satoshi).

Satoshis are created every 10 minutes or so by the mining of a Bitcoin block. This means that blocks are naturally ordered in time — there is a first block, namely the genesis block mined by Satoshi Nakamoto. We call this block 0. As I write this sentence, the current block is 774,984, which makes it the seven hundred seventy-four thousand nine hundred and eighty-fifth block.

Each block allows the miner to create some satoshis, and the number of satoshis they are allowed to create depends on how many blocks have gone before. This is called the “block reward” or “block subsidy” and is created in the first transaction of the block, which is called the “coinbase transaction”. Remember them, because those terms will turn up again several times.

Miners mining the first 210,000 blocks were allowed to create five billion satoshis for each block. Then the block subsidy halved. And every 210,000 blocks it halves again (and is rounded down if there are fractions of satoshis in the reward). These events, where the block height is a multiple of 210,000 are called “halvings”.

Eventually, this means the block subsidy will become 0, and that is what puts a cap on the total number of satoshis that can ever exist.

The mystery of the missing satoshis

Articles all over the web will tell you that the total supply of bitcoin is 21 million, but that is an approximation. I put together a quick spreadsheet which, if I’ve calculated correctly, puts the accurate total supply of satoshis at 2,099,999,997,690,000. This is due to the rounding that happens at the 9th, 15th, 18th, 25th, 27th and 29th halvings.

So here we have Rodamor’s first assumption — all satoshis that can be created will be created, or should be considered to have been created, even if they weren’t.

Therefore you may think we will have a first satoshi, a second satoshi, and so on right up to a 2,099,999,997,690,000th satoshi. But this is not the case — miners are not obliged to claim the block subsidy.

For example, in block 124724 the miner claimed one satoshi less than they could have. This means that satoshi 623625999999999 never existed, and that means the ordinal for the first satoshi of block 12475 should be one lower than expected. Or does it?

It can be argued that a more “natural” ordering of satoshis would take the missing satoshi into account, but that is a pain in the neck to handle in a computer program. So Rodamor has taken the simpler step of assuming the full block reward will be claimed, and so there are going to be numbered satoshis that will never exist.

I can’t blame Rodamor for taking the easier approach. Only the most pedantic software developer wouldn’t.

And now — the ordering!

Given that the blocks are ordered, based on the time at which they were found, we can apply a coarse ordering for the satoshis that are created in a block.

The first block contains satoshi number 0 (yes, we start counting at zero) through to satoshi 4,999,999,999. The second block contains satoshi number 5,000,000,000 through to satoshi 9,999,999,999, and so on.

You can imagine each block as a canvas bag, and the satoshis generated in the block as apples within that bag. We can label the first bag with the range of identifying numbers (i.e. 0 through 4,999,999,999), and the second bag with its range, and so on.

What we don’t know is the individual number within the range to assign to a given satoshi or apple. But this doesn’t matter — if a particular item is never taken out of the bag, then it doesn’t matter what its number is. So Rodamor introduces the “first in, first out” principle.

Apples for apples

Using our bag of apples analogy, this “first in, first out” principle can be explained as follows: when you take a single apple out of the canvas bag, you label it with the next available number from the range of numbers of the canvas bag.

If you take a bunch of apples out of the canvas bag, then you put them in a smaller bag, and label the smaller bag with the next available range of numbers from the range of number of the canvas bag.

That sounds a bit complicated, so how about an example using small numbers.

Imagine that every ten minutes an apple farm ships out a canvas bag containing 100 apples. They’ve shipped fifty bags already, so that means that five thousand apples have left the farm. That’s apples 0 through to 4999.

Now they’re preparing bag fifty-one.

They put a hundred apples in a bag, label it [5000..5099], and send it off to the grocery store. We now know that the bag contains apple 5006, say, but we don’t know which of the one hundred apples is apple 5006.

At the grocery store, someone asks for six apples. The grocer takes six apples out of bag fifty-one, puts them in a paper bag, and labels it [5000..5005], and then change the label on bag fifty-one to [5006..5099] so they don’t forget.

Finally, you come into the store and ask for an apple. The grocer takes an apple out of the canvas bag, puts it in a paper bag and writes 5006 on it, and changes the label on bag fifty-one to read [5007..5099]. Then the paper bag with 5006 written on it is handed to you.

Congratulations! You are the owner of apple 5006.

Unspent transactions

The bag of apples that the previous customer received, and the bag with one apple that you received are called “unspent transaction outputs” in Bitcoin. Your bag with one apple is available for you to spend, if you happen to be living in a country where bags of apples are an accepted form of payment.

And because every transaction is public on the Bitcoin blockchain, we can track down all the unspent transaction outputs, which is something that we cannot do with bags of apples in the real world.

This means that the transparency of the Bitcoin blockchain allows us to know exactly who owns a particular numbered satoshi, even if we do not know which of the satoshis in their unspent transaction collection it is.

Let us return to the two paper bags of apples in the previous section. You walk out of the shop and bump into the customer just before you who stopped suddenly. Her paper bag tears, and her six apples tumble to the ground. A moment later as you bend down to pick them up, you spill your apple into the pile. And they all look identical.

“Oh, I’m sorry,” she says. “Here, you can have one of my apples as an apology. But what do we do about the numbering?”

Not a problem — they’re tough apples, and so you run back into the store and the grocer kindly gives you two new paper bags, and a pen.

Outside there are seven apples on the ground. You pick up two apples and put them in a bag, and then you pick up the remaining five apples and put them in the second bag. But how do you label the bags?

With the “first in, first out” principle, your new bag is labelled [5000..5001] and her new bag is labelled [5002..5007]. The reason for this is that her apples fell into the pile of apples first (first in), but you took your apple and the one gifted to you as an apology (first out) before bagging her apples.

If you wanted to have apple 5007 (perhaps that number has special significance to you), then you should have collected your own apples last.

This process can get very complicated if there are lots of paper bags of apples being provided as inputs, and lots of new paper bags being labelled as outputs, as regularly happens in Bitcoin transactions, but it is fully traceable. And computer programs are good at parsing data such as the Bitcoin blockchain for tracking this kind of stuff.

The data is all there, and it just involves some thorough accounting work. And accurate labelling.

What about transaction fees?

You probably know more than enough about Ordinals by now, but for those of you with a technical mindset, here is an investigation into the final, and most complex requirement to truly ensure that each satoshi is properly tracked.

The last missing piece is transaction fees. To get miners to accept your Bitcoin transaction it is recommended (but not obligatory) to provide a “tip” for the miner.

In the same way that diners at a restaurant calculate the tip as a percentage of the cost of the meal — 15% in the USA, or 20% or more for good service, in Bitcoin the transaction fee is estimated based on how many transactions are waiting to be processed. Pay a higher transaction fee and your transaction is more likely to be accepted by a miner quicker, just as a waiter is more likely to bring you your food swiftly if they know you tip well.

In a restaurant you can tip by leaving more cash on the table than the bill requires, and Bitcoin transactions work the same way. If you provide more funds as inputs to your transaction than are taken out, the remainder becomes claimable by the miner as part of their coinbase transaction. Remember — that’s the one that allows them to mint the block subsidy.

In figure 1, you can see that 1000 satoshis go in, but only 800 satoshis go out. The remaining unclaimed 200 satoshis can be claimed by the miner including the transaction in a block.

There is, however, no explicit transaction transferring the unclaimed 200 satoshis. In a paper I wrote with Bjorn Bjerke three years ago, we describe them as being destroyed, and then magically recreated with permission in the coinbase transaction, precisely because there is no output from a transaction indicating their transferal.

Rodamor has chosen a different interpretation, which is more evidence that the Ordinals ordering scheme is subjective, and not the one and only numbering scheme for satoshis that could exist.

The Python code that Rodamor provides to explain Ordinals handles the allocation of satoshi ordinals to transaction fee satoshis implicitly, by adding all the ordinals of the inputs to the list of coinbase ordinals, and then removing the ordinals of the outputs. This means that the coinbase transaction ends up keeping unclaimed satoshis from the end of the list of ordinals for each input.

At least, on first inspection it seems that way. Rodamor has chosen transaction fees to be the equivalent of an invisible “last output of the transaction”. Which is, again, what I would do because it’s the simplest approach.

But he could have made them the “first output of the transaction” instead, which would be equally valid. There is even an argument to be made that, because the coinbase transaction occurs before the rest of the standard transactions, the “first in, first out” principle should mean that the transaction fee should comprise the initial ordinals of the inputs.

And if the miner doesn’t claim the transaction fee? Like that lone satoshi from block 124724, those satoshis just … disappear.

--

--

Keir Finlow-Bates
Keir Finlow-Bates

Written by Keir Finlow-Bates

I walk through the woods talking about blockchain

No responses yet