Introduction to Resource Model
Voting power, bandwidth, and energy are critical system resources in the TRON network:
- Voting Power (TP): Used to vote for super representatives.
- Bandwidth (Bandwidth Points): Measures transaction size in bytes stored on the blockchain. Larger transactions consume more bandwidth.
- Energy: Measures computational effort required for TVM operations. Smart contract transactions consume energy.
Notes:
- Regular transactions consume only bandwidth.
- Smart contract operations consume both bandwidth and energy.
Voting Power (TP)
Obtaining TP
- Users gain TP by staking TRX (1 TRX = 1 TP).
- Multiple stakes accumulate TP. Check totals via
wallet/getaccountresource
.
Bandwidth
Calculation Rules
- Consumption: Bandwidth Points = Transaction size × 1 (current rate).
Sources:
- Staked TRX: Share of network’s fixed bandwidth pool (43.2B points).
- Free Daily Allowance: 600 points per account.
- Recovery: Spent bandwidth regenerates over 24 hours.
Balance Check:
Free Bandwidth = freeNetLimit - freeNetUsed Staked Bandwidth = NetLimit - NetUsed
Special Cases
- New Accounts: Burns 0.1 TRX if bandwidth is insufficient.
- Token Transfers: Prioritizes token issuer’s bandwidth before user’s.
Energy
Key Concepts
- Energy Consumption: Paid per smart contract operation (0.00021 TRX/energy).
Priority:
- Staked energy.
- Burned TRX if energy is exhausted.
- Recovery: Regenerates over 24 hours.
Balance Check:
Energy Balance = EnergyLimit - EnergyUsed
FeeLimit Guide
- Purpose: Caps energy costs for users.
Example: If a contract used 18,000 energy historically:
- Estimate 20,000 energy (10% buffer).
With developer covering 90%, user sets:
feeLimit = 20,000 × 210 sun × 10% = 420,000 sun
Dynamic Energy Model
How It Works
- Adjusts energy costs based on contract popularity.
- Energy Factor: Multiplies base cost if usage exceeds thresholds.
Thresholds:
threshold
: 5B energy/6hmax_factor
: 3.4× multiplier
Formula:
Actual Energy = Base Energy × (1 + energy_factor)
Managing Resources
Staking/Unstaking
- Use
freezebalancev2
to stake TRX for resources. - Unstaked TRX has a 14-day lockup period.
Resource Delegation
- Delegate bandwidth/energy via
delegateresource
. - Time-locked delegations require 3-day cooldown.
APIs
Endpoint | Description |
---|---|
wallet/getaccountresource | Check resource balances |
wallet/unfreezebalancev2 | Unstake TRX |
wallet/delegateresource | Delegate resources |
FAQ
Q: How is bandwidth calculated for token transfers?
A: Token issuer’s bandwidth is used first, falling back to user’s staked/free bandwidth or TRX burning.
Q: What happens if a contract fails?
A: Reverts deduct only used energy; crashes/timeouts deduct maximum allocated energy.
Q: Can I cancel unstaking?
A: Yes, use cancelallunfreezev2
to revert pending unstakes.