Docs

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.

Start staking TRX

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

Request
owner_addressstring

Address staking TRX (Base58 or Hex)

frozen_balancenumber

Amount to stake in SUN (1 TRX = 1,000,000 SUN)

resourcestring

Resource type: "BANDWIDTH" or "ENERGY"

visibleboolean

Use Base58 format (default: true)

permission_idnumber

Permission ID for multi-sig accounts

Response Body

Response
txidstring

Transaction ID

visibleboolean

Address format used

raw_dataobject

Transaction raw data

raw_data.contractarray

Contract details

raw_data.ref_block_bytesstring

Reference block bytes

raw_data.ref_block_hashstring

Reference block hash

raw_data.expirationnumber

Transaction expiration time

raw_data.timestampnumber

Transaction timestamp

Error Responses

Errors
Error 1INVALID_RESOURCE

Invalid resource type

Error 2INSUFFICIENT_BALANCE

Not enough TRX

Error 3ACCOUNT_NOT_FOUND

Address doesn't exist

Error 4TAPOS_ERROR

Transaction expired

Implementation Examples

Bash
# 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"
fi

Common Use Cases

1. Auto-Staking System

JavaScript
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

JavaScript
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

JavaScript
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

ResourceRateUsage
Bandwidth~1,000 per TRXRegular transactions
Energy~280 per TRXSmart contract calls
Voting Power1 vote per TRXSR voting

Staking Recommendations by Use Case

Use CaseBandwidth (TRX)Energy (TRX)Total
Basic Wallet1000100
DeFi User5005,0005,500
DApp Developer1,00020,00021,000
Exchange10,00050,00060,000

Best Practices

  1. Keep Reserve - Always keep 50-100 TRX unstaked for fees
  2. Balance Resources - Monitor usage and adjust stakes accordingly
  3. Batch Operations - Stake for both resources in one session
  4. Monitor Rewards - Track staking rewards and compound regularly
  5. 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

Need help? Contact support or visit our TRON documentation.