I'm creating a python script in which I need to make a function to send the xtz from one address to another addresss before the transfer I want to compute the operation cost.Is there any way to calulate the operation cost I'm using pytezos.Like in tauquito is there any estimate function in pytezos?
-
When asking a questions, please remember to always post your code (using the code formatting tools available), listing what you have tried so far and any errors you have encountered: stackoverflow.com/help/how-to-ask– Simon McLoughlin ♦Commented Nov 15, 2022 at 14:29
-
I'm not facing any error in this question I'm asking about how to estimate the gas– Shahbaz AliCommented Nov 16, 2022 at 5:24
-
always post your code anyway. As you can see here, I suggested to you to use a function that you have already tried. I've wasted your time and mine, because you didn't show us your code, or tell us you've already tired that. Please post all relevant code and 100% of the details to avoid delays in async communication– Simon McLoughlin ♦Commented Nov 16, 2022 at 9:51
1 Answer
Have you tried the autofill
method as described in the quickstart
Edit:
After providing more details that you are looking to calculate the fee separately so you can enable max sends.
I've not used pyTezos and i'm not a python developer, I don't know if there are any other shorter ways to do this. What autofill
does is performs a "run_operation" RPC call against a Tezos node, which returns an array of operations and internal_operations. Each returned object will have its gas and storage requirements. You need to add them all up and figure out the fee. Take a look at the libraries code and see if you can re-use any of the existing calculation logic
Reference: Documentation on operation types
-
Yes I've used autofill() function but I want to achieve that if a person tries to send 12xtz to another address first I do compute the operation cost and then substract the operation cost from the amount desire to send(like this 12xtz- operation cost).So like in web3.py we've a function to compute cost of transaction is there any similar function in pytezos? Commented Nov 16, 2022 at 5:27
-
@ShahbazAli i've edited my answer to additional details now that the question is clearer– Simon McLoughlin ♦Commented Nov 16, 2022 at 9:59