TronEnergy Energy डेलिगेशन के लिए संपूर्ण REST API दस्तावेज़ीकरण। एंडपॉइंट्स, पैरामीटर, प्रतिक्रिया प्रारूप और त्रुटि कोड।
मूल यूआरएल:https://api.tronnrg.comप्राधिकरण: कोई आवश्यकता नहीं। सभी एंडपॉइंट सार्वजनिक हैं।
दर सीमा: प्रति आईपी 20 अनुरोध/सेकंड
भुगतान पता:TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx (केवल API से, मैन्युअल किराये के लिए नहीं)
यह काम किस प्रकार करता है
तीन चरण। कोई API कुंजी नहीं, कोई साइन-अप नहीं, कोई वॉलेट कनेक्शन नहीं। स्वामित्व क्रिप्टोग्राफिक रूप से सिद्ध किया जाता है।
संकेत — संदेश पर हस्ताक्षर करें {tx_hash}:{delegate_to} TRX भेजने वाले वॉलेट का उपयोग करके। इससे यह साबित होता है कि आपने प्रतिनिधिमंडल को अधिकृत किया था।
दावा — POST /delegate साथ tx_hash, delegate_to, और signatureEnergy लगभग 3 सेकंड में पहुंच जाती है।
भुगतान पता
TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx
केवल API भुगतान पते पर ही भुगतान करें। यह पता API के माध्यम से प्रोग्रामेटिक इंटीग्रेशन के लिए है। इसका उपयोग मैन्युअल ऊर्जा किराये के लिए न करें। मैन्युअल किराये का पता अलग है और पर उपलब्ध है।tronnrg.com.
इस पते पर TRX भेजें। आपके भुगतान का ट्रांजैक्शन हैश ही डेलीगेशन को सक्रिय करने वाला आपका टोकन है। प्रत्येक हैश का उपयोग केवल एक बार किया जा सकता है।
TRX भेजा गया
Energy प्रतिनिधि
उदाहरण
4 TRX
65,000
मौजूदा वॉलेट में मानक USDT हस्तांतरण (न्यूनतम ऑर्डर)
8 TRX
130,000
पहली बार प्राप्तकर्ता को USDT हस्तांतरण
16 TRX
260,000
एक ही ऑर्डर में चार मानक ट्रांसफर
40 TRX
650,000
दस मानक स्थानान्तरण
100 TRX
1,625,000
लगभग 25 मानक स्थानांतरण — छोटे प्लेटफार्मों के लिए सामान्य
1,000 TRX
16,250,000
अधिकतम ऑर्डर, लगभग 250 स्टैंडर्ड ट्रांसफर
इनके बीच की कोई भी राशि
trx × 16,250
पूरी तरह से रैखिक। कोई स्तर नहीं, कोई पैकेज नहीं, कोई छूट नहीं।
सूत्र:energy = trxSent × 16,250. सीमाएँ: न्यूनतम 4 TRX (65,000 ऊर्जा), अधिकतम 1,000 TRX (16,250,000 ऊर्जा)। ये दोनों API स्तर पर लागू हैं — न्यूनतम से कम राशि को below_minimum फ़ंक्शन के साथ अस्वीकार कर दिया जाता है और रिफंड कर दिया जाता है; अधिकतम से अधिक राशि को डेलीगेशन से पहले ही अस्वीकार कर दिया जाता है। उत्पादन में हार्डकोड करने से पहले हमेशा GET /supply से लाइव मान पढ़ें — नीचे देखें।
GET /supply
GET/supply
मूल्य निर्धारण की जानकारी और भुगतान पता प्राप्त करें। यह केवल सूचनात्मक सुविधा है - ऊर्जा हमेशा उपलब्ध है, भुगतान भेजने से पहले आपको इसकी जांच करने की आवश्यकता नहीं है।
curl https://api.tronnrg.com/supply
const supply = awaitfetch('https://api.tronnrg.com/supply')
.then(r => r.json());
// Energy is always available. Use supply.pay_to for the payment address.
console.log('Pay to:', supply.pay_to);
import requests
supply = requests.get('https://api.tronnrg.com/supply').json()
# Energy is always available. Use supply['pay_to'] for the payment address.print(supply['pay_to'])
$supply = json_decode(
file_get_contents('https://api.tronnrg.com/supply'),
true
);
// if less than you require, wait and retry// Energy is always available. Use $supply['pay_to'] for the payment address.echo$supply['pay_to'];
var client = newHttpClient();
var json = await client.GetStringAsync("https://api.tronnrg.com/supply");
var supply = JsonSerializer.Deserialize<JsonElement>(json);
// Energy is always available. Use pay_to for the payment address.var payTo = supply.GetProperty("pay_to").GetString();
ऊर्जा प्रतिनिधिमंडल का दावा करें। आपको पहले ही ऑन-चेन भुगतान पते पर TRX भेजना होगा। लेन-देन हैश, प्राप्तकर्ता का पता और प्रेषक होने का प्रमाण देने वाला हस्ताक्षर भेजें।
Parameter
Type
Description
tx_hash
string
required
TRX भुगतान का 64-अक्षर वाला हेक्स हैश
delegate_to
string
required
ऊर्जा प्राप्त करने के लिए Tron का पता
signature
string
required
Sign {tx_hash}:{delegate_to} using tronWeb.trx.signMessageV2(). Proves you are the payment sender.
TronNRG संदर्भ आईडी। सहायता संबंधी प्रश्नों के लिए इसे रिकॉर्ड करें।
energy
number
कुल ऊर्जा प्रत्यायोजित
cost
number
TRX चार्ज किया गया
status
string
सफलता पर "प्रतिनिधित्व" किया गया
delegations
array
On-chain delegation transaction hashes. Each tx is verifiable on TronScan. This is your receipt.
GET /health
GET/health
Liveness check for monitoring and uptime tools. Returns 200 OK when the API process is up. Does not check upstream nodes or providers.
Response 200
{ "status": "ok" }
त्रुटि कोड
Every error response has error (stable, machine-readable) and message (human-readable). Always switch on error.
Code
HTTP
Meaning
invalid_tx_hash
400
यह 64 अक्षरों वाली हेक्स स्ट्रिंग नहीं है।
invalid_address
400
यह मान्य Tron पता नहीं है
missing_signature
400
कोई हस्ताक्षर नहीं दिए गए
invalid_signature
401
हस्ताक्षर सत्यापित नहीं हो सके
signature_mismatch
403
हस्ताक्षरकर्ता का पता भुगतान भेजने वाले के पते से मेल नहीं खाता।
hash_already_used
409
लेनदेन हैश पहले ही क्लेम किया जा चुका है
payment_verification_failed
404 / 400
On-chain verification of the payment failed. Read the message field for the specific cause: tx not found yet (404, retry in a few seconds), wrong recipient, not a TRX transfer, or below the 4 TRX minimum.
delegation_failed
400 / 500
Provider could not deliver energy. If the failure happened after the payment was verified, an automatic refund is queued. The error response includes a refund object when this happens.
rate_limited
429
इस आईपी से प्रति सेकंड बहुत अधिक अनुरोध आ रहे हैं। सीमा 20 अनुरोध प्रति सेकंड है।
server_error
500
अप्रत्याशित आंतरिक त्रुटि। कुछ सेकंड में पुनः प्रयास करें।
const result = awaitfetch('https://api.tronnrg.com/delegate', { ... })
.then(r => r.json());
if (result.error) {
switch (result.error) {
case'payment_verification_failed':
// Most common cause: tx not yet indexed. Wait 3s and retry.// Read result.message for the specific cause.break;
case'hash_already_used':
// Already claimed. Don't retry.break;
case'signature_mismatch':
// Signer != payment sender. Sign with the same key that sent TRX.break;
case'delegation_failed':
// Refund queued automatically if payment was verified.if (result.refund) console.log('Refund queued:', result.refund);
break;
}
}
result = requests.post('https://api.tronnrg.com/delegate', json=data).json()
if'error'in result:
if result['error'] == 'payment_verification_failed':
# Most common cause: tx not yet indexed. Wait 3s and retry.passelif result['error'] == 'hash_already_used':
# Already claimed. Don't retry.passelif result['error'] == 'signature_mismatch':
# Signer != payment sender. Sign with the same key.passelif result['error'] == 'delegation_failed':
# Refund queued automatically if payment was verified.pass
if (isset($result['error'])) {
switch ($result['error']) {
case'payment_verification_failed':
// Most common cause: tx not yet indexed. Wait 3s and retry.break;
case'hash_already_used':
// Already claimed. Don't retry.break;
case'signature_mismatch':
// Signer != payment sender. Sign with the same key.break;
case'delegation_failed':
// Refund queued automatically if payment was verified.break;
}
}
Refunds
यदि आपके भुगतान की पुष्टि होने के बाद डेलीगेशन विफल हो जाता है, तो TRX रिफंड स्वचालित रूप से कतार में लग जाता है और प्रेषक के पते पर वापस भेज दिया जाता है। त्रुटि प्रतिक्रिया में रिफंड ऑब्जेक्ट देखें।
Error with refund
{
"error": "delegation_failed",
"message": "Energy delegation failed. Your payment will be refunded.",
"ref": "nrg_d_43",
"refund": {
"type": "queued",
"to": "TSenderAddress",
"amount": 4
}
}
पूर्ण उदाहरण
संपूर्ण एंड-टू-एंड प्रक्रिया: TRX भेजें, हस्ताक्षर करें, पुनः प्रयास के साथ दावा करें। कॉपी करें और चलाएं।
const API = 'https://api.tronnrg.com';
const ADDR = 'TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx';
async functionrentEnergy(delegateTo, trxAmount = 4) {
// 1. Send TRX to the payment addressconst payment = await tronWeb.trx.sendTransaction(ADDR, trxAmount * 1e6);
// 2. Sign: proves you are the senderconst message = `${payment.txid}:${delegateTo}`;
const signature = await tronWeb.trx.signMessageV2(message);
// 3. Claim delegation (retry if tx not indexed yet)let result;
for (let i = 0; i < 3; i++) {
result = awaitfetch(`${API}/delegate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
tx_hash: payment.txid,
delegate_to: delegateTo,
signature,
}),
}).then(r => r.json());
if (!result.error) break;
if (result.error !== 'payment_verification_failed') throw newError(result.message);
await newPromise(r => setTimeout(r, 3000));
}
if (result.error) throw newError(result.message);
return result;
}
// Usage — send any amount between 4 and 1,000 TRXconst result = awaitrentEnergy('TWalletThatNeedsEnergy', 4); // 4 TRX → 65k energy// rentEnergy(addr, 8) // → 130,000 energy (new-wallet transfer)// rentEnergy(addr, 40) // → 650,000 energy (10 transfers)// rentEnergy(addr, 1000) // → 16,250,000 energy (max)
console.log(result.energy); // trxAmount × 16,250
console.log(result.delegations[0].tx); // on-chain tx hash
console.log(result.ref); // "nrg_d_42"
import requests
import time
API = 'https://api.tronnrg.com'
ADDR = 'TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx'defrent_energy(delegate_to, trx_amount=4):
# 1. Send TRX to ADDR (via your Tron library)
tx_hash = send_trx(ADDR, trx_amount) # your TRX send function# 2. Sign: proves you are the sender
message = f'{tx_hash}:{delegate_to}'
signature = tron.trx.sign_message_v2(message)
# 3. Claim delegation (retry if tx not indexed yet)for attempt inrange(3):
result = requests.post(f'{API}/delegate', json={
'tx_hash': tx_hash,
'delegate_to': delegate_to,
'signature': signature,
}).json()
if'error'not in result:
return result
if result['error'] != 'payment_verification_failed':
raiseException(result['message'])
time.sleep(3)
raiseException('Transaction not found after retries')
# Usage
result = rent_energy('TWalletThatNeedsEnergy', 4)
print(f"Delegated: {result['energy']} energy")
print(f"Delegation tx: {result['delegations'][0]['tx']}")
print(f"Ref: {result['ref']}")
# 1. Send TRX to TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx# Pricing is linear at 16,250 energy per TRX.# Min 4 TRX (65,000 energy), max 1,000 TRX (16.25M energy).# (use your wallet or tronweb CLI)# 2. Sign the message {tx_hash}:{delegate_to} (proves you are the sender)# (use tronWeb.trx.signMessageV2 in your code)# 3. Claim delegation with tx hash + signature
curl -X POST https://api.tronnrg.com/delegate \
-H "Content-Type: application/json" \
-d '{
"tx_hash": "YOUR_PAYMENT_TX_HASH",
"delegate_to": "TWalletThatNeedsEnergy",
"signature": "YOUR_SIGNATURE"
}'# Response includes delegations[].tx — the on-chain hash you can verify on TronScan