The recent spike in the price of Bitcoin, and the halving event which took place earlier this month caused a spike in the transaction fees paid by senders. This has been a topic of discussion for quite a while, on how fees are calculated and ways to regulate transaction by paying low fees but still getting such transaction confirmed at an acceptable time.
What are transaction fees?These are fees paid on each transaction being sent from one address to another on the Bitcoin network. The fees are paid to the miner who successfully adds the transaction to their confirmed block and the fees are also always paid by the sender of the bitcoins.
Some wallets allow spenders to select the fees they wish to pay to get a particular transaction confirmed based on the priority, basically, the higher the fees, the faster the transaction and vice versa. However there are other variables that affects which transaction would get picked first by miners. To fully understand transaction fees one has been able to to how transactions are effected:
When bitcoins are sent from one address to another, the private key of the sending address is used to sign the transaction, it is then sent to the mempool where it is verified by nodes, who confirm that such inputs are in the sending address, the transaction is then moved to miners who add it to their block based on priority. When a block is confirmed, it is verified by nodes and the transaction is complete and irreversible.
Each Bitcoin is represented on the public ledger or blockchain, this serves as a record of all transactions [arranged chronologically] that has been made over time. Bitcoin supply increases whenever miners successfully confirm a block, because they receive a reward or coinbase. This transaction has no source and can not be dated back, they basically come out of thin air, any subsequent transaction has to have an input and an output
Inputs are bitcoins received into an address from a spender and outputs are bitcoins sent to a receiving address.
How are transaction fees calculated?The amount a spender would pay to get an output confirmed depends on two variables;
• The feerate
• The transaction sizeTHE FEERATE: this is the amount miners charge for each byte of space in their block.
Each transaction takes up space in a block based on it's size, hence there is a limit to the amount of transactions that can be added, also only whole transactions can be added. Hence, miners try to maximize the space available by taking the most profitable transactions.
- Each block has a maximum space (used to be less than or equal to 1 mega byte but due to the implementation of segwit transaction now has a maximum size of 4mb)
- Transactions which are calculated in bytes are added to it until it gets filled.
- Feerates are calculated in Satoshi per byte (sat/byte)
- The amount of Satoshi that would be paid on every byte of space in a block is dependent on the interaction of demand and supply on the Bitcoin network. If there is a higher activity on the network, due maybe to a rise in market price, this could create a lag and spenders would increase their transaction fees to get it confirmed faster, this increases the average feerate on each transaction added to a block.
TRANSACTION SIZE: as I mentioned earlier, blocks contain 1mb of space and transactions are added based on their fees and size. This means that every transaction has a size. Transaction size is simply the number of inputs and outputs involved in it.
If I wish to send 0.5
BTC which I received from two separate transactions (0.2/0.3) this means I have 2 inputs involved in the transaction. This transaction is then sent to the mempool where nodes verify the transactions, this is a way of confirming that I truly own those inputs in my address.
Outputs is the outgoing bitcoins, typically when sending to one address, you should have 1 output, but it's actually 2, the second one is the change address which received the unspent inputs.
Take for example, I have 3 inputs 0.2
BTC, 0.4
BTC and 0.2
BTC totalling to 0.8
BTC and I wish to send 0.7
BTC, all 3 inputs would need to be compiled but not all will be spent, the unspent inputs gets sent back to me through a change address
The larger the number of inputs and outputs involved in a transaction the bigger it's size. Due to the different types of of addresses the size of a transaction is more complicated to calculate manually. You can use this link to find an estimate of your transaction's size -
https://coinb.in/#feesTo determine the transaction fee, you multiply the transaction size by the current feerate. The amount of bitcoins being sent does not influence it.
*Scipt complexity also influences transaction size.
How to minimize transaction fees?With the current spike in fees, many would be interested in ways to reduce the fees. To reduce the fees one or both of the variable involve has to be reduced.
The standard feerate is determined by the level of activity in the network, so;
• timing your transactions can result in significantly lower fees. During a FOMO period, lots of investors are looking to get in and more traders are active, this is probably not a good time to transact, if it's not time sensitive, when the resulting activity cools, the feerate would also reduce, leading to lower transaction fees.
Reducing the transaction size would also reduce the fees incurred, this can be done through a couple of ways:
•
Reducing the number of inputs: the higher the number of inputs involved in a transaction, the higher the size, so to reduce the size, less inputs should be spent.
If I receive 0.4
BTC and spend that in a single transaction, the size would be smaller than a 0.2
BTC transaction comprising two separate inputs (0.1,0.1
BTC).
• Batching receptients : add multiple receiving addresses to a single transaction saves more cost than sending them in separate transactions.
•
Consolidateling inputs and outputs: when an entire input involved in a transaction is not spent, this creates the need for a change address to receive the unspent coins. Spending the exact amount of an input would eliminate the need for a change address hence reducing the amount of outputs and also the transaction size.
Note that, inputs weigh more in a transaction and reducing them should be prioritized when looking to reduce fees.
•
Using a Segwit address: for a detailed explanation on how segwit functions, check out this thread -
https://bitcointalksearch.org/topic/m.52985661
Higher transaction fees and lower size means a transaction is likely to get picked by a miner and confirmed much faster. If you're not in a particular hurry, you can select a minimal fee and wait for it to get confirmed. If a fee is too low a transaction can remain pending till it is dropped from the mempool (this takes ~ 72hours). If this happens the transaction is cancelled and the inputs are returned to the wallet.
I have a question here: if a transaction gets cancelled, is it returned through a change address?
If your transaction remains in the mempool for a long time and you wish to have it confirmed, you can do this through;
•
Replace-by-fee•
Child-Pays-For-ParentAnother protocol aimed at making transactions more efficient, but not directly linked to the Bitcoin network is:
•
Lightening NetworkOther links:
•
Bitcoin fee calculator and estimator