andelf / tronpy

TRON Python Client Library.
MIT License
212 stars 96 forks source link

How to perform Estimated energy #116

Closed d1ksim closed 8 months ago

d1ksim commented 1 year ago

I want to calculate the commission before transferring USDT, but I do not see an implementation for this, it does not work out through a smart contract.

Do you have an example of this implementation? Thank you in advance.

MrNaif2018 commented 8 months ago

This is a complicated process, the easiest is to use Bitcart.

Then you can easily do

bitcart-cli -c trx get_default_fee your_tx_dict_here

It is complex because you need to get two parts: energy consumed by smart contract, and size of transaction. Both impact the fee. Calculating size of transaction is even more complex task which I solved by writing my own library: https://github.com/bitcart/trontxsize/