# Help me work out a transaction fee

I am having difficulty working out how to work out a transaction fee. I've read the theory, but don't understand how to get the values to put the theory to practice.

Can someone please help me work this out step by step? If I want to send 0.05XBT from: `mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1` to `mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g`. How do I work out the transaction fee?

If your answer could use these public keys so I can try them out based on the instructions in your answer, I would really appreciate that.

Using bitcoin-qt's command line, I have the following details:

listunspent [ { "txid" : "9df9c897af413505c02f158a7421b39000b40248a3bb826831ff458aee84f8ca", "vout" : 1, "address" : "mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1", "account" : "From http://faucet.xeno-genesis.com/", "scriptPubKey" : "76a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac", "amount" : 1.19994817, "confirmations" : 364 } ]

Then I could use this:

But this "assumes" a 0.0002XBT fee.

I can then sign the transaction like so:

Which gives me this:

Which is 452 bytes.

Apparently I am supposted count the number of inputs and outputs too? I understand that the fee can get more complex based on the age of the transaction and if I send a very small amount. But just for example purposes, How would I work out the transaction fee using the 2 public keys above if I wanted to send 0.05XBT? so I can subtract the fee from the change when using the `createrawtransaction` command in bitcoin-qt?

I can calculate the priority of the transaction (527 confirmations currently, ~452 bytes):

``````119994817 * 527 / 452 = 139,905,461
``````

Since this is over the minimum of 57,600,000 and meets the other rules for free transactions: namely, that the transaction is under 1000 bytes and has no outputs under 0.01 BTC, this transaction can be free. You do not need to include a transaction fee: make the sum of the outputs equal the input amount exactly.

If your transaction didn't meet the requirements for a free transaction, or if you don't wish it to be treated as a free transaction (which have some limits in transmitting, etc. that might slow down their inclusion in a block), you would need to include 0.0001 BTC transaction fee per thousand bytes (e.g. up to 1000 bytes is 0.0001, 1001-2000 bytes is 0.0002, etc.)

(this is assuming the testnet has the same rules for transaction fees as Bitcoin's mainnet)

• How about the number of inputs and outputs? How do I get those values? – oshirowanen Jun 10 '14 at 18:29
• You already specified that when you said "If I want to send 0.05XBT from: mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1 to mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g.". Since mvDLEE... only has one unspent output credited to it, you must have one input. And since you only want to give a portion of that to mxgx... you must have at least one change address. Unless you're adding unnecessary complexity, then, the number of inputs is 1 and the number of outputs is 2. In some cases, the transaction fee might change this, but this is a simple example. – Tim S. Jun 10 '14 at 18:41