5

I come from a programming background and I am trying to figure out how Bitcoin allows for divisibility. An example using high level code would also be nice.

I understand the high level basics of transactions (Bitcoin Transaction Diagram), but I am interested in divisibility specifically.

2 Answers 2

8

A bitcoin is divisible to the eighth decimal. The smallest portion of Bitcoin has its own name: satoshi, whereas 1 BTC = 10^8 satoshis = 100,000,000 satoshis

To be completely correct, while in popular conversation the bitcoin is the predominant currency unit, in realitas the protocol uses satoshi. You can see this when looking at raw transactions or the ledger.

Whenever you send a Bitcoin transaction, the inputs are destroyed and new outputs are created. Essentially, what happens with Bitcoin works like this: Imagine you are paying for a $5 ice cream with a $10 bill, and the $10 bill is destroyed and replaced by two $5 bills, of which you get one $5 bill and one $5 bill goes to the ice cream vendor.

I was not able to deduce what you are trying to get code for, but if you want to split up bitcoins for transactions you might be looking for more information on how to create raw transactions, as dannypaz pointed out in the comments, the Bitcoin Wiki's page on transactions may also be illustrative.

2
  • Your answer is great @Murch. I wanted to add to this, that you can see another example here: en.bitcoin.it/wiki/Transaction which also helped me understand the concept
    – dannypaz
    Mar 25, 2018 at 5:51
  • @dannypaz: Thanks, I've added your link as an additional example.
    – Murch
    Mar 26, 2018 at 16:44
2

All transactions are actually stored and transmitted in satoshis (one hundred millionths of a bitcoin or bitcoin × 108). So really, it is not divisibility, as much as it is converted by multiplying in the UI. It's always satoshis, but shown as various bigger units.

If you divide the the number of satoshis by 100m you get the value in bitcoin. If instead of dividing by 100m, you divide by 100k, you get mBTC (millibitcoin), if you divide by 100 you get μBTC (microbitcoin).

5
  • I don't think this is accurate. Bitcoins are divisible to satoshis, but transactions are sent in the desired amount. My understanding is that when a miner signs a block, that becomes the bitcoins, where this one unit was originally equal to 50 bitcoins. There being 50 bitcoins to a block was just an abstraction for the value of a block.
    – Zamicol
    Sep 11, 2013 at 19:33
  • 3
    @Zach: aantonop is actually right, in the underlying protocol bitcoin values are always written as satoshis. I will also correct that in my answer.
    – Murch
    Sep 12, 2013 at 12:29
  • @Zach: no, you're confusing the monetary unit and blocks. Blocks are lists of transaction and form an authorative history for the network. Blocks are allowed to contain one transaction that conjures new currency out of nothing, under strictly controlled conditions, called the miner subsidy. So blocks do introduce new coins, they are not coins, and the amounts are always internally represented as multiples of a satoshi, even for subsidies. Sep 13, 2013 at 23:43
  • Thanks Pieter and Murch! If I broke a ten dollar bill into two units, a $2.85 unit and a $7.15 cent unit, amounts are measured in pennies, but these units don't necessarily need to be transmitted or stored in pennies. The only case this would happen is if I actually broke them out into pennies.
    – Zamicol
    Sep 14, 2013 at 23:25
  • 1
    Now I get what you were talking about. Yes, units are of variable size in the network and their value is measured in satoshis.
    – Murch
    Sep 15, 2013 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.