wallet/freezebalancev2 - Stake TRX for Resources
Stake TRX to obtain bandwidth or energy resources on TRON network, earn rewards, and participate in network governance via Dwellir's reliable RPC endpoint.
Resource Management V2
Dwellir's TRON infrastructure supports the latest Stake 2.0 mechanism for efficient resource management. Stake TRX to get bandwidth/energy while earning rewards and voting rights.
Freeze (stake) TRX balance to obtain bandwidth or energy resources using the Stake 2.0 mechanism. Staked TRX earns rewards and provides voting power for Super Representatives.
Use Cases
wallet/freezebalancev2 is essential for:
- Resource Acquisition - Get bandwidth for transactions
- Energy Generation - Power smart contract interactions
- Reward Earning - Earn staking rewards (~4-7% APR)
- Governance Participation - Gain voting power for SRs
- DApp Operations - Ensure smooth contract execution
Request Parameters
Address staking TRX (Base58 or Hex)
Amount to stake in SUN (1 TRX = 1,000,000 SUN)
Resource type: "BANDWIDTH" or "ENERGY"
Use Base58 format (default: true)
Permission ID for multi-sig accounts
Response Body
Transaction ID
Address format used
Transaction raw data
Contract details
Reference block bytes
Reference block hash
Transaction expiration time
Transaction timestamp
Error Responses
Invalid resource type
Not enough TRX
Address doesn't exist
Transaction expired
Implementation Examples
# Freeze TRX for ENERGY
curl -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/freezebalancev2" \
-H "Content-Type: application/json" \
-d '{
"owner_address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN",
"frozen_balance": 10000000000,
"resource": "ENERGY",
"visible": true
}'
# Freeze TRX for BANDWIDTH
curl -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/freezebalancev2" \
-H "Content-Type: application/json" \
-d '{
"owner_address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN",
"frozen_balance": 5000000000,
"resource": "BANDWIDTH",
"visible": true
}'
# Parse response with jq
curl -s -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/freezebalancev2" \
-H "Content-Type: application/json" \
-d '{
"owner_address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN",
"frozen_balance": 10000000000,
"resource": "ENERGY",
"visible": true
}' | jq '{
txid: .txid,
resource: .raw_data.contract[0].parameter.value.resource,
amount_sun: .raw_data.contract[0].parameter.value.frozen_balance,
amount_trx: (.raw_data.contract[0].parameter.value.frozen_balance / 1000000),
expiration: .raw_data.expiration
}'
# Script to calculate and stake optimal amounts
#!/bin/bash
API_KEY="YOUR_API_KEY"
ADDRESS="TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN"
# Function to stake TRX
stake_trx() {
local amount_sun=$1
local resource=$2
echo "Staking $((amount_sun / 1000000)) TRX for $resource..."
response=$(curl -s -X POST \
"https://api-tron-mainnet.n.dwellir.com/$API_KEY/wallet/freezebalancev2" \
-H "Content-Type: application/json" \
-d "{
\"owner_address\": \"$ADDRESS\",
\"frozen_balance\": $amount_sun,
\"resource\": \"$resource\",
\"visible\": true
}")
txid=$(echo "$response" | jq -r '.txid')
if [ "$txid" != "null" ]; then
echo "✓ Transaction created: $txid"
echo " Please sign and broadcast this transaction"
else
echo "✗ Failed to create transaction"
echo "$response" | jq .
fi
}
# Calculate resources needed
echo "=== Resource Staking Calculator ==="
echo
read -p "Daily transactions expected: " daily_tx
read -p "Daily smart contract calls expected: " daily_contracts
# Calculate requirements (approximate)
bandwidth_needed=$((daily_tx * 250))
energy_needed=$((daily_contracts * 50000))
trx_for_bandwidth=$((bandwidth_needed / 1000))
trx_for_energy=$((energy_needed / 280))
echo
echo "Resource Requirements:"
echo " Bandwidth needed: $bandwidth_needed"
echo " Energy needed: $energy_needed"
echo
echo "TRX to stake:"
echo " For Bandwidth: $trx_for_bandwidth TRX"
echo " For Energy: $trx_for_energy TRX"
echo " Total: $((trx_for_bandwidth + trx_for_energy)) TRX"
echo
read -p "Proceed with staking? (y/n): " confirm
if [ "$confirm" = "y" ]; then
# Convert to SUN and stake
stake_trx $((trx_for_bandwidth * 1000000)) "BANDWIDTH"
sleep 2
stake_trx $((trx_for_energy * 1000000)) "ENERGY"
fiCommon Use Cases
1. Auto-Staking System
class AutoStakingSystem {
constructor(apiKey) {
this.staking = new TronStakingManager(apiKey);
this.minBalance = 1000; // Minimum TRX to keep unstaked
}
async autoStake(address, keepBalance = 1000) {
// Get current balance
const account = await this.getAccount(address);
const availableTRX = (account.balance / 1_000_000) - keepBalance;
if (availableTRX <= 0) {
return { message: 'Insufficient balance for staking' };
}
// Split 30% bandwidth, 70% energy (typical DApp usage)
const bandwidthTRX = Math.floor(availableTRX * 0.3);
const energyTRX = Math.floor(availableTRX * 0.7);
return await this.staking.stakeForResources(
address,
bandwidthTRX,
energyTRX
);
}
}2. Resource Optimization
async function optimizeResources(address) {
const resources = await getAccountResource(address);
// Check utilization
const bandwidthUtil = resources.freeNetUsed / resources.freeNetLimit;
const energyUtil = resources.EnergyUsed / resources.EnergyLimit;
const recommendations = [];
if (bandwidthUtil > 0.8) {
recommendations.push({
action: 'STAKE',
resource: 'BANDWIDTH',
reason: 'High bandwidth utilization',
suggestedTRX: 1000
});
}
if (energyUtil > 0.8) {
recommendations.push({
action: 'STAKE',
resource: 'ENERGY',
reason: 'High energy utilization',
suggestedTRX: 5000
});
}
return recommendations;
}3. Staking Pool Management
class StakingPool {
async distributeStakes(participants, totalTRX) {
const stakes = [];
for (const participant of participants) {
const share = (participant.contribution / 100) * totalTRX;
stakes.push({
address: participant.address,
amount: share,
resource: participant.preferredResource || 'ENERGY'
});
}
return this.executeStakes(stakes);
}
}Resource Calculation
| Resource | Rate | Usage |
|---|---|---|
| Bandwidth | ~1,000 per TRX | Regular transactions |
| Energy | ~280 per TRX | Smart contract calls |
| Voting Power | 1 vote per TRX | SR voting |
Staking Recommendations by Use Case
| Use Case | Bandwidth (TRX) | Energy (TRX) | Total |
|---|---|---|---|
| Basic Wallet | 100 | 0 | 100 |
| DeFi User | 500 | 5,000 | 5,500 |
| DApp Developer | 1,000 | 20,000 | 21,000 |
| Exchange | 10,000 | 50,000 | 60,000 |
Best Practices
- Keep Reserve - Always keep 50-100 TRX unstaked for fees
- Balance Resources - Monitor usage and adjust stakes accordingly
- Batch Operations - Stake for both resources in one session
- Monitor Rewards - Track staking rewards and compound regularly
- Plan Unstaking - Remember 14-day waiting period for unstaking
Notes
- Lock Period: Staked TRX has a minimum 14-day lock period
- Rewards: Staking rewards are distributed every 6 hours
- Voting Power: Staked TRX provides voting power for Super Representatives
- Resource Recovery: Bandwidth recovers 24 hours, energy recovers based on consumption
Related Methods
- wallet/unfreezebalancev2 - Unstake TRX
- wallet/delegateresource - Delegate resources
- wallet/getaccountresource - Check resources
Need help? Contact support or visit our TRON documentation.
wallet/estimateenergy
Estimate energy consumption for TRON smart contract calls before execution. Optimize transaction costs and resource planning with Dwellir RPC.
wallet/unfreezebalancev2
Unstake TRX to reclaim resources (bandwidth/energy) on TRON network via Dwellir's optimized RPC endpoint with Stake 2.0 support.