Docs

wallet/undelegateresource - Reclaim Delegated R...

Reclaim delegated TRX resources (bandwidth/energy) from other TRON accounts via Dwellir's high-performance RPC endpoint.

Reclaim previously delegated bandwidth or energy resources from another account.

Endpoint

Text
POST /wallet/undelegateresource

Request Parameters

Request
owner_addressstring

Required parameter: Account address that delegated resources (base58)

receiver_addressstring

Required parameter: Account that received delegated resources (base58)

balancenumber

Required parameter: Amount to undelegate in SUN (1 TRX = 1,000,000 SUN)

resourcestring

Required parameter: Resource type: "BANDWIDTH" or "ENERGY"

permission_idnumber

Optional parameter: Permission ID for multi-signature (default: 0)

visibleboolean

Optional parameter: Return base58 addresses (default: false returns hex)

Response Body

Response
resultOBJECT

`txID` - Transaction hash `raw_data` - Transaction raw data `contract` - Undelegation contract details `expiration` - Transaction expiration timestamp `timestamp` - Transaction creation timestamp `visible` - Address format indicator

Important Notes

Undelegation Rules

  1. Lock Period Check: Cannot undelegate if resources are locked
  2. Immediate Effect: Resources return to owner immediately after confirmation
  3. Partial Undelegation: Can undelegate portions of delegated amount
  4. Resource Availability: Reclaimed resources are immediately available to owner
  5. No Waiting Period: Unlike unstaking, undelegation has no waiting period

Key Differences from Unstaking

  • Undelegation: Returns delegated resources to owner (immediate)
  • Unstaking: Converts staked TRX back to liquid (14-day wait)

Implementation Examples

Bash
# Basic undelegation of energy
curl -X POST https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/undelegateresource \
  -H "Content-Type: application/json" \
  -d '{
    "owner_address": "TOwnerAddress...",
    "receiver_address": "TReceiverAddress...",
    "balance": 1000000000,
    "resource": "ENERGY",
    "visible": true
  }'

# Undelegate bandwidth
curl -X POST https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/undelegateresource \
  -H "Content-Type: application/json" \
  -d '{
    "owner_address": "TOwnerAddress...",
    "receiver_address": "TReceiverAddress...",
    "balance": 500000000,
    "resource": "BANDWIDTH",
    "visible": true
  }'

# Check delegation index (to find all delegations)
curl -X POST https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getdelegatedresourceaccountindex \
  -H "Content-Type: application/json" \
  -d '{
    "value": "TOwnerAddress...",
    "visible": true
  }'

# Get specific delegation details
curl -X POST https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getdelegatedresource \
  -H "Content-Type: application/json" \
  -d '{
    "fromAddress": "TOwnerAddress...",
    "toAddress": "TReceiverAddress...",
    "visible": true
  }'

# Check receiver's resource usage (to analyze efficiency)
curl -X POST https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getaccountresource \
  -H "Content-Type: application/json" \
  -d '{
    "address": "TReceiverAddress...",
    "visible": true
  }'

Undelegation Process Flow

mermaid
graph LR
    A[Delegated Resources] --> B{Check Lock Status}
    B -->|Locked| C[Wait for Unlock]
    B -->|Unlocked| D[Initiate Undelegation]
    C --> D
    D --> E[Sign Transaction]
    E --> F[Broadcast]
    F --> G[Resources Returned to Owner]
    
    style A fill:#2196F3
    style B fill:#FF9800
    style G fill:#4CAF50

Best Practices

1. Check Lock Status First

JavaScript
// Always check before attempting undelegation
const status = await checkUndelegationStatus(owner, receiver, resource);
if (!status.canUndelegate) {
  console.log(`Cannot undelegate: ${status.reason}`);
  return;
}

2. Monitor Utilization

  • Regularly check delegation efficiency
  • Reclaim underutilized resources
  • Redistribute based on actual needs

3. Batch Operations

  • Group multiple undelegations together
  • Reduces transaction costs
  • Easier to manage

4. Grace Period Management

  • Track lock expiration dates
  • Set reminders for locked delegations
  • Plan undelegations in advance

Common Errors

ErrorDescriptionSolution
No delegation foundNo resources delegated to receiverCheck delegation status first
Delegation is lockedResources are locked for periodWait for lock period to expire
Insufficient delegated balanceTrying to undelegate more than delegatedCheck current delegation amount
Invalid resource typeMust be BANDWIDTH or ENERGYUse correct resource string

Use Cases

  • Resource Reallocation: Move resources to more active users
  • Cost Optimization: Reclaim resources from inactive accounts
  • Emergency Recovery: Quickly reclaim resources when needed
  • Delegation Cleanup: Remove old or unnecessary delegations
  • Efficiency Management: Optimize resource distribution based on usage