---
updatedAt: 2026-11-20T07:59:14.000Z
agentTools:
  projectIndex: https://developers.tron.network/llms.txt
---

# Smart contract errors

Diagnostic flows for the runtime errors developers hit most often on TRON — OUT_OF_TIME, REVERT, OUT_OF_ENERGY, missing constant_result, TRC-20 Energy variance, and Stake 2.0 permission-denied failures.

> 📘 **Prerequisites**
>
> * [Smart contracts introduction](https://developers.tron.network/docs/smart-contracts-introduction)
> * [VM exception handling](https://developers.tron.network/docs/vm-exception-handling)

This page is the diagnostic reference for the runtime errors developers see most often when writing or invoking TRON smart contracts. Each section gives the cause, how to confirm it, and the concrete fix. For the full exception-type taxonomy at the protocol layer, see [VM exception handling](https://developers.tron.network/docs/vm-exception-handling).

***

## OUT\_OF\_TIME — CPU timeout or protocol check failure

`OUT_OF_TIME` does not always mean that execution exceeded the CPU time limit. In addition to an actual timeout, java-tron explicitly returns this result when certain protocol checks fail. Use the transaction's specific error message to identify the cause.

Whether an actual timeout or a protocol check triggers the result, `OUT_OF_TIME` exhausts the Energy allowance available to the contract execution; any portion still unused at failure is also recorded as consumed. Do not treat it as an ordinary `REVERT`. See [VM exception handling](https://developers.tron.network/docs/vm-exception-handling).

The 80 ms budget is **chain parameter `#13`** (API key `getMaxCpuTimeOfOneTx`); the SR committee can modify it through proposals. Query the live value via `wallet/getchainparameters` — do not hard-code 80 in your application.

If the same call sometimes triggers `OUT_OF_TIME` and sometimes does not, the contract is sitting on the boundary — different SR machine performance pushes some calls past the limit and not others.

### OUT\_OF\_TIME triggered directly by protocol checks

In addition to elapsed CPU-time limits, some protocol checks trigger `OUT_OF_TIME` directly. Diagnose the failure from the transaction's exact error message.

| Error message                                                  | Cause                                                                                                                                                                                                                                                                 |
| :------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CPU timeout for 0x0a executing`                               | `ValidateMultiSign` detects the same signer address represented by different signature bytes                                                                                                                                                                          |
| `CPU timeout for contract hash fields`                         | `code_hash` or `trx_hash` is non-empty in the contract deployment input                                                                                                                                                                                               |
| `CPU timeout for FreezeBalanceV2 after SELFDESTRUCT`           | An account calls `freezebalancev2` after executing `SELFDESTRUCT` earlier in the same transaction                                                                                                                                                                     |
| `CPU timeout for SELFDESTRUCT with selfdestructed beneficiary` | The `SELFDESTRUCT` beneficiary has already executed `SELFDESTRUCT` in the same transaction                                                                                                                                                                            |
| `CPU timeout for invalid delegated V2 balance`                 | `unfreezebalancev2`, `cancelallunfreezev2`, or `withdrawexpireunfreeze` detects a negative outbound delegated Stake 2.0 balance                                                                                                                                       |
| `CPU timeout for storage check`                                | Distinct storage locations accessed during a contract execution map to the same legacy storage key, which can trigger a storage-conflict check. Legacy-data read protection enabled by parameter `#102` (`getAllowOptimizeTvmStorageKey`) can also trigger this error |

The `SELFDESTRUCT` marker exists only in the current transaction's execution context; it does not permanently prevent the account from staking.

A private chain or test environment that has not activated the current TVM rules may also return `CPU timeout for create2 executing` or `CPU timeout for modExp executing`. Under the current Mainnet rules, the corresponding boundary conditions produce operation-level failures instead of `OUT_OF_TIME`. See [TVM opcodes](https://developers.tron.network/docs/opcodes).

The following recommendations apply only when the contract's actual execution time exceeds the limit.

**Fixes for elapsed-time CPU timeout**:

* **Split the operation across multiple transactions.** Design expensive operations as resumable batches, process a bounded amount of work per transaction, and record progress in contract state. When deploying a large contract, keep the constructor lightweight and perform substantial initialization afterward in multiple transactions. Moving code into separate contracts and calling them within the same transaction does not reset that transaction's CPU deadline.
* **Replace recursion with iteration** where possible — iterative loops are cheaper in both Energy and execution time.
* **Avoid unbounded loops over storage arrays** — these are the most common cause. Cache reads, paginate, or move the work to off-chain processing.
* **Re-estimate Energy under realistic conditions.** Test with the same input sizes you expect in production, not just minimal cases.
* **Calibrate `fee_limit` to the contract's actual complexity.** An excessive value increases the Energy budget that an `OUT_OF_TIME` failure may exhaust; the resulting TRX burn also depends on the caller's available staked Energy and balance.

For temporarily bypassing the transaction execution time limit in an isolated test environment, see [Node operations issues — bypass the transaction execution time limit in an isolated test environment](https://developers.tron.network/docs/node-operations-issues#bypass-the-transaction-execution-time-limit-in-an-isolated-test-environment).

***

## REVERT — diagnostic flow

A `REVERT` indicates that the contract intentionally aborted, for example because a `require` check failed or the contract executed `revert`. Only the Energy used before the failure is charged; the unused Energy allowance is not billed.

**Diagnostic flow**:

1. **Check the transaction's `contractResult` field** via `wallet/gettransactioninfobyid`. The hex-encoded reason string follows the `08c379a0` selector (the `Error(string)` ABI-encoded prefix). Decode it with any hex-to-string tool.

   Example: `txid: e5e013e81cb50a4c495a11c8130ad165a4e98d89b9e3fb5b79e6111bf23b31ed` returns:

   ```json
   {
     "contractResult": [
       "08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001e536166654d6174683a207375627472616374696f6e206f766572666c6f770000"
     ]
   }
   ```

   After removing the selector, offset, and length fields, decode the string bytes beginning with `53`: `536166654d6174683a207375627472616374696f6e206f766572666c6f77`. This yields **`SafeMath: subtraction overflow`**. Prefer an ABI decoder for the complete `Error(string)` payload.

2. **If `contractResult` is empty**, the revert came from a `require` assertion without a message string. Read the contract source code and identify which `require` could have failed for the inputs you used. For the full ABI-encoded error format including Solidity 0.8.4+ custom errors, see [Errors and debugging](https://developers.tron.network/docs/errors).

3. **Look for `require()` or `revert()` calls** along your function's code path. Confirm each precondition is met for the inputs you used.

4. **Check fund-related preconditions**: insufficient TRX balance, insufficient TRC-20 allowance, expired deadlines, paused contracts.

5. **For low-level `.call()` failures**, the call returns `false` rather than reverting — make sure your code propagates that flag back as a `revert`.

For Solidity 0.8.4+ custom errors, the selector is the first 4 bytes of `keccak256("ErrorName(types)")` — use the contract ABI to decode parameters.

***

## OUT\_OF\_ENERGY — ran out of Energy mid-execution

`OUT_OF_ENERGY` means the contract execution requires more Energy than is available. The available allowance consists of the Energy the caller can cover and any Energy the contract deployer can contribute. The caller's contribution is limited by their available resources, TRX balance, and `fee_limit`. For calculation details, see [Resource Payment and Energy Sharing](https://developers.tron.network/docs/paying-for-resources).

If the transaction ultimately fails with `OUT_OF_ENERGY`, the state changes made during contract execution are reverted, but the entire Energy allowance available to that execution is still consumed.

**Fixes**:

1. **Re-estimate Energy** with the production-shape inputs through `wallet/triggerconstantcontract` or `wallet/estimateenergy`. A self-hosted FullNode disables `estimateenergy` by default; enable both `vm.estimateEnergy = true` and `vm.supportConstant = true`. Public RPC support depends on the provider, so fall back to `triggerconstantcontract` when the endpoint is unavailable. See [FeeLimit & Energy cost](https://developers.tron.network/docs/set-feelimit) for the full estimation flow.

2. **Adjust `fee_limit` based on the Energy estimate.** Ensure the caller has enough Energy or TRX to cover their share. The current Mainnet `fee_limit` maximum is **15,000 TRX**; an eligible deployer can contribute additional Energy. If the available Energy is still insufficient, consider optimizing the contract or splitting the operation.

3. **Verify the contract's `consume_user_resource_percent`** isn't set so that the caller bears more than they can afford. Re-check the math in [FeeLimit & Energy cost](https://developers.tron.network/docs/set-feelimit).

4. **Check for a Dynamic Energy Model surcharge.** Popular contracts get a per-cycle `energy_factor` multiplier on top of base Energy cost. Query it through `wallet/getcontractinfo`.

5. **Top up TRX or stake for Energy.** A contract call will fail if the initiating address has insufficient TRX to cover the required Energy or Bandwidth costs. For high-volume callers, stake TRX for Energy via [Stake 2.0](https://developers.tron.network/docs/staking-on-tron-network) or rent Energy via the [JustLend Energy Rental market](https://app.justlend.org/energyRental).

For the Energy / fee\_limit / origin\_energy\_limit interactions in full detail, see [FeeLimit & Energy cost](https://developers.tron.network/docs/set-feelimit).

***

## Empty `constant_result` when calling a `view` or `pure` method

You receive an empty `constant_result` array when triggering a `view` or `pure` method via `wallet/triggerconstantcontract`. The call appears to "do nothing" — no return value, no error.

**Cause**: This is a known issue when a node was downgraded from GreatVoyage-v4.2.2 (Lucretius) or later to GreatVoyage-v4.2.1 (Origen) / v4.2.0 (Plato). The downgraded node's database is missing fields the constant-call path expects.

**Fix** (node operators):

1. Stop the node and back up the entire data directory; do not let any other node process keep writing to it.
2. Upgrade the node binary to the latest java-tron version. Do not keep using a data directory that was written by a newer-version node and then opened by an older-version node.
3. Restore from a trusted snapshot matching the target version and `storage.db.engine`, or re-sync from the genesis block into an empty data directory.
4. Once the node catches up, verify the block height and read-only call results via `/wallet/getnowblock` and `/wallet/triggerconstantcontract`, then restore external service; keep the original backup until recovery is confirmed.

The legacy `DBRepair.jar` guide and download link have been removed from the current java-tron repository. Do not download a similarly named JAR from third-party sources; if you cannot verify the tool's source, use the "upgrade the node + restore from a trusted snapshot or re-sync" flow.

If you are not running your own node and seeing empty `constant_result`, switch to a different RPC provider (TronGrid, QuickNode) — the issue is at the node operator level, not in your contract.

***

## Two transfers of the same TRC-20 token cost different Energy

This is mainly caused by two factors: the storage state of the recipient account, and the Dynamic Energy Model.

### Recipient storage state (the `SSTORE` cost)

Many TRC-20 contracts store account balances in a mapping. In these implementations, updating the recipient's balance slot executes `SSTORE`:

* When the slot changes from zero to nonzero, that `SSTORE` consumes **20,000 Energy**.
* When an already nonzero slot is updated, that `SSTORE` consumes **5,000 Energy**.

The difference between these writes is 15,000 Energy, but this is only one storage operation within the transfer. A transfer can also update the sender's balance, write other state, and run contract-specific logic, so the total transaction does not necessarily cost four times as much. The TRC-20 standard does not require this storage layout; use the target contract's implementation and an Energy estimate to determine the actual cost.

### Dynamic Energy Model

The [Dynamic Energy Model](https://developers.tron.network/docs/paying-for-resources#dynamic-energy-model) adjusts a contract's penalty factor based on its resource usage in the previous maintenance cycle. The same TRC-20 transfer can therefore consume different amounts of Energy in different cycles. Re-estimate Energy before sending.

### TRC-20 transfer Energy examples

**USDT** (high-volume, dynamic-energy-affected):

* Transfer to an address with USDT balance > 0: \~64,000 Energy. [Example](https://tronscan.io/#/transaction/60a254a511a6ecf9b3e180770c22fdc864fb1f221976822fa1332d26b6402d16)
* Transfer to an address with USDT balance = 0: \~130,000 Energy. [Example](https://tronscan.io/#/transaction/c1f8ec2e4a7c3260206832517d6217894229c6230b06e1dd98c9af615c608882)

The exact numbers fluctuate with USDT's `energy_factor`; consumption near these magnitudes is normal.

**BTT** (no dynamic-energy surcharge):

* Transfer to an address with BTT balance > 0: \~13,253 Energy. [Example](https://tronscan.io/#/transaction/32e11d0b9b9e0db33c29fe5bc2b9a2c82e5b027954e3a1320cb02ed30fae8a65)
* Transfer to an address with BTT balance = 0: \~28,253 Energy. [Example](https://tronscan.io/#/transaction/c6b06b116c264305860b12d471ae7a8716cc8839f3738546632dbe1377695a7b)

For cost predictability, estimate Energy immediately before broadcasting (or use the on-chain `max_factor` for an upper bound). See [FeeLimit & Energy cost](https://developers.tron.network/docs/set-feelimit) for the three calibration strategies.

***

## "Permission denied" when using Account Permission Management for Stake 2.0

For accounts activated before Stake 2.0 took effect on Mainnet ([committee proposal #84](https://coredevs.medium.com/committee-proposal-84-a3e0894bebd8)), initiating Stake 2.0 operations through the Account Permission Management multi-sig flow may return `Permission denied`.

**Cause**: the `operations` field of the selected active permission does not allow the required Stake 2.0 transaction type, so the transaction is rejected.

**Fix**: update the selected active permission's `operations` field to allow the Stake 2.0 transaction types needed by the application:

| Operation                        | ID |
| -------------------------------- | -- |
| `FreezeBalanceV2Contract`        | 54 |
| `UnfreezeBalanceV2Contract`      | 55 |
| `WithdrawExpireUnfreezeContract` | 56 |
| `DelegateResourceContract`       | 57 |
| `UnDelegateResourceContract`     | 58 |
| `CancelAllUnfreezeV2Contract`    | 59 |

The `operations` field is a 32-byte bitmap; bit `n` corresponds to operation ID `n`. Computing the bitmap by hand is error-prone — use a TRON SDK helper (TronWeb, Trident) or the TronLink permission UI.

For the full Account Permission Management flow, see [Multi-signature](https://developers.tron.network/docs/multi-signature).

***

## Related resources

* [VM exception handling](https://developers.tron.network/docs/vm-exception-handling) — full exception-type reference
* [Broadcast and RPC errors](https://developers.tron.network/docs/broadcast-and-rpc-errors) — pre-execution validation errors and broadcast response codes
* [Node operations issues](https://developers.tron.network/docs/node-operations-issues) — sync, startup, stability, and the `--debug` bypass
* [FeeLimit & Energy cost](https://developers.tron.network/docs/set-feelimit) — `fee_limit` calibration and the Dynamic Energy Model
* [Best practices](https://developers.tron.network/docs/best-practices) — pre-deployment checklist
* [Multi-signature](https://developers.tron.network/docs/multi-signature) — Account Permission Management
* [FAQ](https://developers.tron.network/docs/faq) — Q\&A hub