Estimate Transaction Fee
Transaction Fee
Transaction fees are certain amounts to pay for your transactions, smart contract deployment and execution on the blockchain which, as incentives, directly go to miners or validators who verify and validate transactions for you. The calculation of transaction fees are related to the transaction fee model of a blockchain; each blockchain has its own transaction fee model.
For most blockchains, we must choose the amount to pay for transaction fees. If the transaction fee is inappropriate, you may encounter the following issues:
- Transaction fee too high: While the time required to complete a transaction can be greatly reduced, excessive transaction fees can lead to overpaying for transaction fees and result in loss of funds.
- Transaction fee too low: If a transaction fee is too low, the confirmation process will be slowed down, prolonging the time required to execute the transaction and possibility rejecting it due to insufficient fees.
Estimate Transaction Fee
Since the majority of blockchains alter transaction costs based on on-chain congestion, we cannot specify a fixed fee for a transaction or transaction type. The fee is instead approximated depending on the blockchain's particular fee model and other real-time variables. There are 2 ways to estimate the transaction fee when APIs are used to create transactions:
- Configure Transaction Fee Tier
- Configure Fee Model Parameters Based on Corresponding Blockchains
The 2 aforementioned methods above are supported by transaction creating-related interfaces. If used at the same time, Configure Fee Model's Parameters Based on Corresponding Blockchain has precedence over Configure Transaction Fee Tier.
Configure Transaction Fee Tier
Different blockchains have different transaction fee models. To make it easy for developers to create transactions via the Safeheron API, we provided the parameter txFeeLevel
of Configure Transaction Fee Tier in transaction creating-related interfaces to simplify the transaction fee estimation. As a result, the transaction fee tier you choose determines the transaction fees based on the transaction fee model of the respective blockchain, and is unaffected by the differences between various transaction models. There are three tiers for transaction fee:
Tier | Description |
---|---|
LOW | The low tier is the minimal transaction fee needed to complete a transaction. It may cause a transaction to take longer to complete if transaction fees fluctuate. |
MIDDLE | The middle tier represents an appropriate transaction fee. If there are no specific requests, this tier is recommended. |
HIGH | High-tier transaction fees are relatively expensive. This tier should be utilized if you want the transaction to be completed as quickly as possible. |
Configure Fee Model Parameters Based on Corresponding Blockchains
The parameter of chain's fee model feeRateDto
in transaction creating-related interfaces supports you have precise control over the transaction fee. You can use the Estimate Transaction Fee API to estimate the fee model parameters for a transaction. Users who are familiar with the transaction fee models of multiple blockchains can more accurately estimate the fee model's parameters.
Select Transaction Fee Settings
Users who are not familiar with transaction fee models of various blockchains or do not desire precise control over transaction fees should set up a Transaction Fee Tier to streamline the fee calculation. User who wish to have precise control of transaction fees, can set up fee model parameters for the corresponding blockchain to estimate transaction fees.