<p>I am using <a href="https://ofek.dev/bit/guide/transactions.html" rel="nofollow noreferrer">bit library</a> to make a Bitcoin transaction.<br />
I can use methods like this:</p>
<pre><code>key.create_transaction([('1Archive1n2C579dMsAu3iC6tWzuQJz8dN', 190, 'jpy')])
</code></pre>
<p>or</p>
<pre><code>key.send([('1Archive1n2C579dMsAu3iC6tWzuQJz8dN', 190, 'jpy')])
</code></pre>
<p>However, I'm wondering how can I get the transaction size in bytes <strong>so i can estimate the transaction fee</strong>.</p>

CC BY-SA 4.0
2023-05-24T12:54:53.030Z
Related: https://bitcoin.stackexchange.com/q/103654/5406, https://bitcoin.stackexchange.com/a/75124/5406, https://bitcoin.stackexchange.com/a/84006/5406.
Murch
CC BY-SA 4.0
2023-05-24T13:20:57.637Z
@Murch Unfortunately, everyone only explains, it seems that everyone is a good speaker in this matter.
But no one can provide sample code.
Everyone says to get this first and then that, but how to get the necessary amounts?
reza_khalafi
CC BY-SA 4.0
2023-05-24T13:42:07.973Z
Standard output types have known weights. You can just hardcode the upperbound values for the inputs and outputs. The latter two linked questions include these vsizes, the last even in table format. If you want to calculate them yourself, there is a whole series of topics about different input and output types where the size and weight is deduced from the bytes they are composed of, all tagged with [tag:transaction-weight] e.g. https://bitcoin.stackexchange.com/q/111395/5406, https://bitcoin.stackexchange.com/q/111395/5406, https://bitcoin.stackexchange.com/q/108283/5406
Murch
CC BY-SA 4.0
2023-05-24T13:51:39.753Z
If you don’t mind reading Typescript, this library has code for transaction weight calculations: https://github.com/BitGo/BitGoJS/tree/master/modules/unspents/src
Murch
<transactions><transaction-fees><python><transaction-weight>
How to get transaction size as byte before send with Python's bit library?
reza_khalafi
# How to get transaction size as byte before send with Python's bit library?

(Asked by: username_0 on 2023-05-24)

I am using bit library to make a Bitcoin transaction.
I can use methods like this:
key.create_transaction([('1Archive1n2C579dMsAu3iC6tWzuQJz8dN', 190, 'jpy')])

or
key.send([('1Archive1n2C579dMsAu3iC6tWzuQJz8dN', 190, 'jpy')])

However, I'm wondering how can I get the transaction size in bytes so i can estimate the transaction fee.

**Tags:** transactions, transaction-fees, python, transaction-weight

> **Comments:**
> **username_1**: Related: https://bitcoin.stackexchange.com/q/103654/5406, https://bitcoin.stackexchange.com/a/75124/5406, https://bitcoin.stackexchange.com/a/84006/5406.  
> **username_0**: @username_1 Unfortunately, everyone only explains, it seems that everyone is a good speaker in this matter. But no one can provide sample code. Everyone says to get this first and then that, but how to get the necessary amounts?  
> **username_1**: Standard output types have known weights. You can just hardcode the upperbound values for the inputs and outputs. The latter two linked questions include these vsizes, the last even in table format. If you want to calculate them yourself, there is a whole series of topics about different input and output types where the size and weight is deduced from the bytes they are composed of, all tagged with [tag:transaction-weight] e.g. https://bitcoin.stackexchange.com/q/111395/5406, https://bitcoin.stackexchange.com/q/111395/5406, https://bitcoin.stackexchange.com/q/108283/5406  
> **username_1**: If you don’t mind reading Typescript, this library has code for transaction weight calculations: https://github.com/BitGo/BitGoJS/tree/master/modules/unspents/src  

---

## 0 answers

