What you have to know about fees
It’s important to understand that the transaction fees will increase if you increase the priority of the transaction. A higher priority will increase the fee so that it will be able to successfully compete with other transactions in order to become part of the next block on the blockchain.
Another thing worth mentioning is that the transaction fee will also increase if you are sending funds that you were originally sent via more small transactions. The reason for which this will happen is the fact that the size of the transaction data will be much larger.
Monero has an adaptive block size, and this means that most of the time, users will not be forced to increase the priority of their transactions and pay higher fees in order to get their transactions processed.
In order to support microtransactions, both Bitcoin and Monero are likely to support systems such as the Lightning network in order to reduce the costs of smaller payments in the future significantly.
Transaction version: 1 VarInt
Unlock time: 1 VarInt
Per Input: 1 byte (type: either coinbase or regular spend) + 1 VarInt (pre-ringct amount) + 1 VarInt (the ring size) + Ring_Size VarInts (input offsets) + 32 bytes (key image)
Per Output: 1 VarInt (pre-ringct amount) + 1 byte (type: only regular spend type currently implemented) + 32 bytes (output one-time public key)
Tx extra: Includes 32 bytes for the txpubkey, may contain an encrypted or unencrypted payment id, a nonce if a coinbase tx, and can contain other arbitrary user defined information
Tx type: 1 byte (Version 2 transactions only)
Tx fee: 1 VarInt
Version 1 transactions only: 1 LSAG ring signature per input, each ring signature is 32 bytes * Ring_Size
Version 1 transactions end here. The remainder of the transaction structure applies to Version 2 (RingCT) transactions only:
PsuedoOuts (newly generated commitments for the real input amounts, so that your real inputs are not revealed): Per input: 32 bytes (PseudoOuts are present for tx type 2 RCTType2Simple transactions only)
EcdhInfos (encrypted output amounts and OutPk commitment masks): 64 bytes per output
OutPks (output amount commitments): 32 bytes per output
Range proofs: 6176 bytes per output
MLSAG ring signatures: Per Input: (64 bytes * Ring_Size) + 32 bytes
Basically, in order to calculate transaction cost, you will need to multiply the result of the get_fee_estimate Wallet RPC call to the transaction size.
In order to do this, you will need the following:
- The base transaction size
- The number of inputs and size overhead in kb per each input
- The number of outputs and size overhead in kb per each input
- The number of rings and size overhead in kb per each ring
- The dynamic fee per kb