0

Need to receive a network commission for the transaction, as this is done in the trust wallet.

  1. Specify the wallet address
  2. Enter the amount of TRX to send
  3. Click Continue.
  4. And output, example "Network Fee: ~0.265 TRX".

I use PHP language

I've been searching Google for 2 weeks now and can't figure out how to do it.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0
  1. The tron network fee is calculated on the base of the bandwidth required and bandwidth price. 1 byte of transaction byte representation costs 1 bandwidth point. Each bandwidth point requires a TRX amount to be burnt. The actual price of TRX bandwidth point can be retrieved using the following API (getTransactionFee key in the result), the value is SUNs (1 TRX = 1000000 SUNS)

    curl --request GET \
     --url https://api.shasta.trongrid.io/wallet/getchainparameters \
     --header 'accept: application/json'
    
  2. To be more accurate you need to take into account that each account has some free bandwidth points renewed daily.

  3. Sending TRX to a not yet activated account costs 1 TRX for the sender additionally to the bandwidth price.

  4. For trc20 transfer additionally to bandwidth, the energy is used. Energy can be estimated using this API endpoint:

    $ curl -X POST  https://nile.trongrid.io/wallet/triggerconstantcontract -d '{
    "owner_address": "TTGhREx2pDSxFX555NWz1YwGpiBVPvQA7e",
    "contract_address": "TVSvjZdyDSNocHm7dP3jvCmMNsCnMTPa5W",
    "function_selector": "transfer(address,uint256)",
    "parameter": "0000000000000000000000002ce5de57373427f799cc0a3dd03b841322514a8c00000000000000000000000000000000000000000000000000038d7ea4c68000",
    "visible": true
    }'
    

    Energy price also can be retrieved via the API endpoint (getEnergyFee key in the result):

    curl --request GET \
         --url https://api.shasta.trongrid.io/wallet/getchainparameters \
         --header 'accept: application/json'
    

    Also the common practice is to usually increase this value by multiplying with some factor to make sure the energy estimation will be enough to pay for the transaction execution.

    See the details here: https://developers.tron.network/docs/set-feelimit#how-to-estimate-energy-consumption

I recommend reading the details in the Tron resources model documentation: https://developers.tron.network/docs/resource-model

Nick
  • 144
  • 1
  • 4