Every transaction on a Blockchain has a commission, or fee, incentive to the miner to be prioritized, processed and confirmed.
What is the cost of commissions?
Miners are rewarded for mining and for keeping a Blockchain's network secure.
They receive commissions from each transaction of a block that have previously been prioritized and taken from the Bitcoin mempool for further validation.
Bitcoin Mempool
Recall that the Mempool is that memory space that the Bitcoin Blockchain uses to store unconfirmed transactions. Nodes take transactions with priority to validate and insert into a new block.
The prioritization of a transaction depends on its commission. If it is too low, the transaction may never be confirmed. If its cost is above average, it will be more tempting for miners.
The cost of a commission is manipulable, i.e. we can set how many Satoshis it will be for the miner. It is complex to determine how much money a commission should be, as it depends on the usage of the network at a certain time and the number of transactions waiting in the mempool.
Calculating the cost of a transaction
It might be believed that transferring 1000 BTC is much more expensive than transferring 1 BTC. This is false. Bitcoin fees do not depend on the amount of BTC we transfer or a percentage of them.
Commissions in the Bitcoin network depend on the amount of inputs and outputs used in the transaction. So a transaction of 1000 BTC could be cheaper than transferring 1 BTC.
When transferring value in BTC, the commission depends on the amount of outputs with which the amount to be sent is built. If we have 100 outputs that make up 1 BTC, the commission is more expensive than transferring 1000 BTC made up of a single output.
This is due to the amount of logical processing and the amount of memory the nodes will need to commit a transaction. If nodes need to process 100 outputs, it will be more expensive than processing just one and this determines the commission cost. The complexity and size and not on the value to be transferred.
Bitcoin does not understand about dollars
As people, we usually use the US dollar or the euro to establish the value of a digital asset such as bitcoin. Bitcoin does not understand, and does not care, how much its value is in dollars. That is a value established by exchanges through supply and demand. The Bitcoin Blockchain only understands units of BTC or Satoshis.
The fee for a transaction is implicit in the transaction. There is no field within the transaction that indicates the fee for the miner. This is calculated with the formula Fees = Sum(inputs) - Sum(outputs)
.
If we want to transfer 2 BTC using outputs that make up 5 BTC, we would get 3 BTC back. These 3 BTC must be set as exchange or return output to their source address explicitly. If this is not done, the 3 BTC will be the miner's commission so be very careful.
Conclusion
The mechanism behind Bitcoin to establish the cost of commissions is complex and with many variables to take into account in order not to make a mistake when transferring money.
Many of the concepts seen here, such as the calculation of commissions depending on the state of the network or the return value, should not worry us if we use wallets such as Metamask, since they perform all the calculations for us and even allow us to customize the cost of transactions.
These are all concepts to keep in mind if we want to work with Bitcoin and develop our own programs for value transfer.
Contributed by: Kevin Fiorentino (Platzi Contributor).
Want to see more contributions, questions and answers from the community?