delegate-energy - TRON energy
Example code for the delegate-energy JSON RPC method
This endpoint delegates energy to a TRON address. In most cases, the order completes immediately with status "success".
Parameter
target_address
string
Yes
TRON wallet address (starts with T, 34 characters)
volume
integer
Yes
Energy amount: 30,000 — 5,000,000
duration
string
Yes
"1h", "1d", "3d", "7d"
Idempotency
delegateEnergy charges your balance and may place an on-chain order. To make retries safe, send a unique key with each intent:
Idempotency-Key: 6f9c2a1e-3b7d-4c08-9f21-2e5a7c0b1d44A UUID is recommended. Generate a new key for each purchase, and reuse the same key when retrying the exact same purchase.
Same key + same body
The original response is replayed. No second charge, no second order.
Same key + different body
422
Same key on a different endpoint
409
Duplicate sent while the first is still in flight
409 with a Retry-After header
Idempotency store temporarily unavailable
503 with a Retry-After header (retry shortly)
Request Sample
curl -X POST https://services.getblock.io/v1/tron-energy/delegate-energy \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6f9c2a1e-3b7d-4c08-9f21-2e5a7c0b1d44" \
-d '{
"target_address": "TUo8pycbvje...zw67bpPs4GLFyD",
"volume": 65000,
"duration": "1h"
}'import axios from 'axios';
const data = JSON.stringify({
"target_address": "TUo8pycbvje...zw67bpPs4GLFyD",
"volume": 65000,
"duration": "1h"
}
);
const config = {
method: 'post',
url: 'https://services.getblock.io/v1/tron-energy/delegate-energy',
headers: {
'Content-Type': 'application/json',
'Authorization: Bearer YOUR_API_KEY'
'Idempotency-Key: 6f9c2a1e-3b7d-4c08-9f21-2e5a7c0b1d44' \
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data)))
.catch(error => console.log(error));Response
Last updated
Was this helpful?