TronEnergy Energy وفد کے لیے مکمل REST API دستاویزات۔ اختتامی نقطے، پیرامیٹرز، رسپانس فارمیٹس، اور ایرر کوڈز۔
بنیادی URL:https://api.tronnrg.comتصدیق: کوئی ضرورت نہیں۔ تمام اختتامی مقامات عوامی ہیں۔
شرح کی حد: 20 درخواستیں/سیکنڈ فی آئی پی
ادائیگی کا پتہ:TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx (صرف API ، دستی کرایے کے لیے نہیں)
یہ کیسے کام کرتا ہے۔
تین قدم۔ کوئی API کلید، کوئی سائن اپ، کوئی والیٹ کنکشن نہیں۔ ملکیت خفیہ طور پر ثابت ہے۔
دستخط - پیغام پر دستخط کریں۔ {tx_hash}:{delegate_to} بٹوے کا استعمال کرتے ہوئے جس نے TRX بھیجا تھا۔ اس سے ثابت ہوتا ہے کہ آپ نے وفد کو اختیار دیا ہے۔
دعویٰ - POST /delegate کے ساتھ tx_hash، delegate_to، اور signature. Energy ~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 حوالہ ID۔ سپورٹ کے سوالات کے لیے اسے لاگ ان کریں۔
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
اس IP سے فی سیکنڈ بہت زیادہ درخواستیں حد 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