TRONSCAN CLASS — Contract trigger

TRONSCAN
2 min readJun 10, 2019

--

Trigger function

Once the TRON smart contracts are deployed, their functions can be triggered individually either via TronStudio or through API calls. State-changing functions require energy while read-only functions execute without energy.

Gaining energy

Energy can only be obtained by freezing the TRX. Energy obtained = the TRX frozen for gaining Energy / the total TRX frozen for gaining Energy in the entire network * 100,000,000,000, which is the equally-divided fixed Energy for all users based on the frozen TRX.

For example, suppose the total amount of TRX frozen for gaining Energy is 1,000,000,000 TRX in the current network, and one account freezes 1000 TRX, which is one-millionth of the total and equals 100,000 microseconds. If executing a contract takes 1000 microseconds, then the user can trigger the contract 100 times.

Note

・Since the total frozen funds in the network and the frozen funds of accounts may change at any time, the CPU resources owned by accounts are not fixed.

・One cannot get both Bandwidth Points and Energy when freezing funds. If you freeze TRX to get bandwidth, then your Energy will not change.

If you wish to estimate energy costs for deploying or triggering smart contract, please refer to Tron Station which has an energy tool can help you.

Illegal operations and penalties

Illegal operations/invalid operation codes compiled from smart contracts not only fail to deploy/execute, but also incur a full penalty of the fee_limit. As users normally set the fee limit to 1000 TRX (max), this is a significant penalty and is even more costly if the user attempts to retry the operations automatically.

There are two common ways invalid operation codes are triggered:

・User is manually trying to inject arbitrarily invalid operation code into the smart contract bytecode.

・User is using a newer compiler before new operation codes are supported. Specifically as a past example, before the “TRC-10 token transfer in smart contracts” is allowed (https://tronscan.org/#/proposal/15), if user happens to use the new compiler to deploy/execute smart contracts, the full fee_limit would be deducted from the user account.

--

--

TRONSCAN
TRONSCAN

Written by TRONSCAN

Explore the TRON World | http://tronscan.org | Tele: https://t.me/tronscan_org #TRON #TRX $TRX #TRONSCAN

No responses yet