# How is the monetary part of bitcoin stored?

How is the monetary aspect of a bitcoin stored? I understand that the blockchain is a set of records documenting transactions. I've also seen that blockchains in general can store arbitrary information (such as contracts, small notes, etc).

What I don't understand is how monetary values are recorded, exchanged, and divided.

Is a literal number value encrypted into the transaction? Or is it something more abstract?

• – Murch
Sep 28, 2019 at 22:20

Within the Bitcoin protocol, each Bitcoin is represented as 100000000 satoshis. Therefore, you can divide bitcoin up with a precision of 0.00000001.

In a transaction, the number of satoshis being delivered to each output is recorded, along with a record of which previous output is being spent.

The fee is then derived from `sum(Inputs) - sum(Outputs)`. The actual representation of the amount itself is encoded using the Variable Length Integer representation

How is the monetary aspect of a bitcoin stored?

There is no such thing as a Bitcoin in normal Bitcoin usage. Bitcoin is a currency but it does not have the equivalent of a physical coin that passes around. Bitcoin is really a unit of measure not a coin or anything much like a coin.

Where the monetary aspect is stored depends on where you look.

Bitcoin full nodes such as the Bitcoin-core wallet, send and receive data to other nodes that are primarily blocks of the blockchain. Every full-node maintains its own copy of the blockchain. As you know, the blockchain is simply a list of transactions and the information about a transaction is only a list of input amounts and a list of output amounts. Each amount being associated with a script that usually contains a Bitcoin-address which is almost always under the control of some unidentified person.

As you know, to work out the total unspent amount of money currently associated with an address you can look through the whole blockchain, add an amount everytime that address appears in an output and subtract an amount every time that address appears in an input.

Since people nowadays use a new address for every transaction, to calculate a total for a person you'd have to know a list of addresses under the control of that person. That information is not in the blockchain data but is stored in the person's wallet (and not shared with anyone else).

A wallet could choose to have a file that contains the person's name, or an account-number and the number representing the total amount of money controlled by that person or account. But whether or how wallets do this and how they store this data is not really part of any Bitcoin definition or specification. Each wallet could choose to do this or not and to do it in a unique way.

You have to divide this question into two parts. Your confusion arises from the fact that there is no account per person like a bankaccount.

1 - If there is no account where does the knowledge of who owns how many bitcoin comes from?

The blockchain contains of information about amounts of bitcoins that have been sent to addresses. So, it knows how many bitcoin each address owns and spent in the sense that each transaction contains an address and an amount of bitcoins.

Someone interested in how many bitcoin a certain receiver owns has to add and substract all those amounts from those transactions for a certain address and do this for a set of addresses that belong to a certain receiver.

2 - How much is a bitcoin worth?

This depends on the exchange rate of bitcoin to other things. The exchange to dollars happens on bitcoin exchanges and is derived from supply and demand of dollars and bitcoins there.

• The concept of "how many BTC an address has" is still an abstraction provided by block explorers and some wallets; it does not exist at the protocol level. Sep 25, 2019 at 20:48
• @Pieter Wuille yes, i meant in the sense of knowledge in the chain. it is there in a raw form, it has just to be computed from it. Sep 26, 2019 at 4:08
• @PieterWuille Can you share link with good (preferably easy) explanation of the concept at the protocol level? Sep 28, 2019 at 11:36
• Oct 5, 2019 at 6:19