bnb-chain / go-sdk

Apache License 2.0
204 stars 97 forks source link

How to get fee amount from get transaction rpc #52

Closed crossle closed 5 years ago

crossle commented 5 years ago

I use RPC query transaction /tx?hash=_, how to get the transaction fee? i need to know the fee of this transaction

unclezoro commented 5 years ago

hi, for now, there is no fee message in the transaction. If the transaction type is trade(like createOrder), you can find fee in trade api, for other kind of transaction you need get fee parameters from /api/v1/fees, and calculate the fee.

chainwhisper commented 5 years ago

I use RPC query transaction /tx?hash=_, how to get the transaction fee? i need to know the fee of this transaction

trade fee可以从http api 查到: https://dex.binance.org/api/v1/trades?symbol=UGAS-B0C_BNB&start=1562544000000&end=1562630400000&total=1&offset=0&limit=1000

photo_2019-07-16 10 31 08

crossle commented 5 years ago

If the fee changed, how to know the history transfer transaction fee via RPC?

chainwhisper commented 5 years ago

If the fee changed, how to know the history transfer transaction fee via RPC?

You can only get the current fee by querying abci interface.

The fee history is recorded in the fee change proposals.

unclezoro commented 5 years ago

You still have an option: use api

https://explorer.binance.org/api/v1/tx?txHash=0E50ABF5DAA042CBB23A118EF73DD1DD7F1BCED5457EB9E2281D89A25F30CA55

In that API, you will get a fee message. But this is not an official API, may not stable.

crossle commented 5 years ago

It's not a good choice use the explorer.binance.org, it's should query from RPC, i think it's should record on blockchain. I know the query abci can get the current fee, or fee change proposals, it's hard to sure how much fee for this transaction.

unclezoro commented 5 years ago

@crossle you request are reasonable, I also discuss with other members, we may wrap the rest api rather than RPC in future. It would be a breaking change for RPC to support fee info which beyond what an sdk could do, would you clarify your scene and make an issue in https://github.com/binance-chain/BEPs, we could have a serious discussion there.

crossle commented 5 years ago

Thanks your reply. Plz don't breaking RPC, RPC should have all feature, it's low level API, it's just run full node, no any other REST server. REST API is a high level API, it should just a wrapper for RPC, it's just convenience for some developers, but it's dependence REST server, we have to run REST server, it's hard to maintenance. If no REST API, it's ok, the developers can use RPC, If no RPC api, it's very bad, many developers don't like the REST API, it's hard to satisfy almost developers.