⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

wallet/delegateresource

Delegate staked bandwidth or energy resources to another TRON account.

Endpoint

POST /wallet/delegateresource

Parameters

Required Parameters

ParameterTypeDescription
owner_addressstringAccount address delegating resources (base58)
receiver_addressstringAccount receiving delegated resources (base58)
balancenumberAmount to delegate in SUN (1 TRX = 1,000,000 SUN)
resourcestringResource type: "BANDWIDTH" or "ENERGY"

Optional Parameters

ParameterTypeDescription
lockbooleanLock delegation for 3 days (default: false)
lock_periodnumberCustom lock period in seconds (if lock=true)
permission_idnumberPermission ID for multi-signature (default: 0)
visiblebooleanReturn base58 addresses (default: false returns hex)

Response

Returns unsigned transaction containing the delegation operation. Transaction must be signed and broadcast.

Response Fields

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

Important Notes

Delegation Rules

  1. Must Stake First: Resources must be staked before delegation
  2. Immediate Effect: Delegation takes effect immediately after transaction confirmation
  3. Lock Period: Optional 3-day lock prevents immediate reclaim
  4. Resource Ownership: Delegated resources remain owned by delegator
  5. Reclaim Process: Use undelegateresource to reclaim delegated resources

Resource Calculations

  • Energy delegation helps with smart contract execution
  • Bandwidth delegation helps with transactions and transfers
  • Receiver pays no TRX but can use delegated resources

Implementation Examples

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

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

# Check delegation index
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 delegation details between accounts
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
}'

Example Response

{
"visible": true,
"txID": "d8f3c4b9e2a7d6c5e4f3b2a1d9c8e7f6b5a4d3c2e1f9a8b7c6d5e4f3a2b1c9e",
"raw_data": {
"contract": [
{
"parameter": {
"value": {
"owner_address": "TOwnerAddress...",
"receiver_address": "TReceiverAddress...",
"balance": 1000000000,
"resource": "ENERGY",
"lock": true,
"lock_period": 259200
},
"type_url": "type.googleapis.com/protocol.DelegateResourceContract"
},
"type": "DelegateResourceContract"
}
],
"ref_block_bytes": "6b5c",
"ref_block_hash": "4d3e5f9a8b7c6d5e",
"expiration": 1702456849000,
"timestamp": 1702456789000
}
}

Delegation Flow

graph LR
A[Owner Stakes TRX] --> B[Resources Available]
B --> C[Delegate to Receiver]
C --> D[Receiver Uses Resources]
D --> E[Resources Consumed]
E --> F[Owner Can Reclaim]

style A fill:#4CAF50
style C fill:#2196F3
style D fill:#FF9800

Best Practices

1. Calculate Before Delegating

// Always analyze needs first
const needs = await analyzeNeeds(receiverAddress);
const delegateAmount = Math.ceil(needs.energy.deficit / 28.5);

2. Use Locks Strategically

  • Lock for stable, long-term delegations
  • Keep unlocked for flexible, short-term needs
  • Consider 3-day default lock period

3. Monitor Resource Usage

  • Track receiver's consumption patterns
  • Adjust delegations based on actual usage
  • Implement alerts for high usage

4. Batch Operations

  • Group multiple delegations together
  • Reduces transaction overhead
  • Easier management and tracking

Common Errors

ErrorDescriptionSolution
Insufficient staked balanceNot enough staked resourcesStake more TRX first
Invalid resource typeMust be BANDWIDTH or ENERGYUse correct resource string
Receiver address invalidMalformed receiver addressVerify base58 format
Already delegatedResources already delegated to receiverCheck existing delegations

Use Cases

  • DApp Support: Provide resources for users to interact with your DApp
  • Gaming: Enable free gameplay by covering resource costs
  • DeFi Trading: Support traders with energy for smart contract calls
  • Onboarding: Help new users get started without staking
  • Resource Rental: Commercial resource delegation services