Base URL: https://api.tronnrg.com Xác thực: Không bắt buộc. Tất cả các endpoint đều công khai. Giới hạn tốc độ: 20 yêu cầu/giây mỗi IP Địa chỉ thanh toán: TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx (Chỉ API, không cho thuê thủ công)

Cách hoạt động

Ba bước. Không cần API key, không cần đăng ký, không cần kết nối ví. Quyền sở hữu được chứng minh bằng mã hóa.

  1. Gửi TRX — Gửi 4 TRX (hoặc nhiều hơn) đến địa chỉ thanh toán. 4 TRX = 65,000 energy. 8 TRX = 130,000. Tuyến tính.
  2. — Ký pesan {tx_hash}:{delegate_to} bằng ví đã gửi TRX. Điều này chứng minh bạn đã phê duyệt ủy quyền năng lượng.
  3. NhậnPOST /delegate với tx_hash, delegate_to, và signature. Energy tới trong ~3 giây.

Địa chỉ thanh toán

TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx
Chỉ địa chỉ thanh toán API. Địa chỉ này dành cho tích hợp lập trình qua API. Không sử dụng cho thuê energy thủ công. Địa chỉ thuê thủ công khác và có sẵn trên .tronnrg.com.

Gửi TRX đến địa chỉ này. Hash giao dịch thanh toán của bạn là token để kích hoạt ủy quyền năng lượng. Mỗi hash chỉ có thể sử dụng một lần.

TRX đã gửiEnergy ủy quyềnTrường hợp sử dụng
4 TRX65,000Chuyển USDT tiêu chuẩn đến ví hiện có (đơn hàng tối thiểu)
8 TRX130,000Chuyển USDT đến người nhận lần đầu
16 TRX260,000Bốn chuyển tiêu chuẩn trong một đơn hàng
40 TRX650,000Mười chuyển tiêu chuẩn
100 TRX1,625,000~25 chuyển tiêu chuẩn — thường gặp cho nền tảng nhỏ
1,000 TRX16,250,000Đơn hàng tối đa, ~250 chuyển tiêu chuẩn
Bất kỳ số lượng nào trong khoảng nàytrx × 16,250Hoàn toàn tuyến tính. Không có tầng, không có gói, không có chiết khấu.
Công thức: energy = trxSent × 16,250. Giới hạn: tối thiểu 4 TRX (65,000 energy), tối đa 1,000 TRX (16,250,000 energy). Cả hai được thực thi ở cấp API — số lượng dưới mức tối thiểu bị từ chối với below_minimum và được hoàn lại; số lượng vượt quá mức tối đa bị từ chối trước khi ủy quyền năng lượng.

POST /delegate

POST/delegate

Yêu cầu ủy quyền năng lượng. Bạn phải đã gửi TRX đến địa chỉ thanh toán trên chuỗi. Cung cấp hash giao dịch, địa chỉ người nhận và chữ ký chứng minh bạn là người gửi.

Tham sốLoạiMô tả
tx_hashstringbắt buộcHash hex 64 ký tự của khoản thanh toán TRX
delegate_tostringbắt buộcĐịa chỉ Tron nhận năng lượng
signaturestringbắt buộctronWeb.trx.signMessageV2() của tronWeb.trx.signMessageV2(). Chứng minh bạn là người gửi thanh toán.
curl -X POST https://api.tronnrg.com/delegate \ -H "Content-Type: application/json" \ -d '{"tx_hash":"TX_HASH","delegate_to":"TWallet","signature":"SIG"}'
const result = await fetch('https://api.tronnrg.com/delegate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ tx_hash: 'YOUR_TX_HASH', delegate_to: 'TWalletAddress', signature: 'YOUR_SIGNATURE', }), }).then(r => r.json()); if (result.error) { console.error(result.error, result.message); } else { console.log('Delegated:', result.energy, 'energy'); console.log('Ref:', result.ref); }
import requests response = requests.post('https://api.tronnrg.com/delegate', json={ 'tx_hash': 'YOUR_TX_HASH', 'delegate_to': 'TWalletAddress', 'signature': 'YOUR_SIGNATURE', }) result = response.json() if 'error' in result: print(f"Error: {result['error']} - {result['message']}") else: print(f"Delegated: {result['energy']} energy") print(f"Delegation tx: {result['delegations'][0]['tx']}") print(f"Ref: {result['ref']}")
$ch = curl_init('https://api.tronnrg.com/delegate'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_POSTFIELDS => json_encode([ 'tx_hash' => 'YOUR_TX_HASH', 'delegate_to' => 'TWalletAddress', 'signature' => 'YOUR_SIGNATURE', ]), ]); $result = json_decode(curl_exec($ch), true); curl_close($ch); if (isset($result['error'])) { echo "Error: " . $result['message']; } else { echo "Delegated: " . $result['energy'] . " energy"; }
var client = new HttpClient(); var content = new StringContent( JsonSerializer.Serialize(new { tx_hash = "YOUR_TX_HASH", delegate_to = "TWalletAddress", signature = "YOUR_SIGNATURE" }), Encoding.UTF8, "application/json" ); var response = await client.PostAsync("https://api.tronnrg.com/delegate", content); var json = await response.Content.ReadAsStringAsync(); var result = JsonSerializer.Deserialize<JsonElement>(json); if (result.TryGetProperty("error", out var err)) Console.WriteLine($"Error: {err}"); else Console.WriteLine($"Delegated: {result.GetProperty("energy")} energy");
Phản hồi 200
{ "ref": "nrg_d_42", "delegate_to": "TWalletAddress", "energy": 65000, "cost": 4, "status": "delegated", "delegations": [ { "tx": "a1b2c3d4e5f6...your delegation tx hash", "energy": 65000 } ] }
TrườngLoạiMô tả
refstringMã tham chiếu TronNRG. Ghi lại để hỗ trợ.
energynumberTổng năng lượng được ủy quyền
costnumberTRX được tính phí
statusstring"delegated" nếu thành công
delegationsarrayHash giao dịch ủy quyền trên chuỗi. Mỗi tx có thể xác minh trên TronScan. Đây là biên nhận của bạn.

GET /health

GET/health

Kiểm tra tính sẵn sàng cho các công cụ giám sát và thời gian hoạt động. Trả về 200 OK khi quy trình API hoạt động. Không kiểm tra các node hoặc nhà cung cấp hạ nguồn.

Phản hồi 200
{ "status": "ok" }

Mã lỗi

Mỗi phản hồi lỗi có error (ổn định, có thể đọc bởi máy) và message (có thể đọc bởi con người). Luôn chuyển đổi trên error trong mã của bạn.

HTTPÝ nghĩa
invalid_tx_hash400Không phải chuỗi hex 64 ký tự
invalid_address400Không phải địa chỉ Tron hợp lệ
missing_signature400Không có chữ ký được cung cấp
invalid_signature401Không thể xác minh chữ ký
signature_mismatch403Địa chỉ ký không khớp với người gửi thanh toán
hash_already_used409Hash giao dịch đã được yêu cầu
payment_verification_failed404 / 400Xác minh thanh toán trên chuỗi thất bại. Đọc trường message để biết nguyên nhân cụ thể: giao dịch chưa tìm thấy (404, thử lại trong vài giây), người nhận sai, không phải chuyển TRX, hoặc dưới mức tối thiểu 4 TRX.
delegation_failed400 / 500Nhà cung cấp không thể cung cấp năng lượng. Nếu lỗi xảy ra sau khi thanh toán được xác minh, một khoản hoàn tiền sẽ tự động được xếp hàng chờ. Kiểm tra đối tượng refund khi điều này xảy ra.
rate_limited429Quá nhiều yêu cầu mỗi giây từ IP này. Giới hạn là 20/giây.
server_error500Lỗi nội bộ không mong đợi. Vui lòng thử lại sau vài giây.
const result = await fetch('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. pass elif result['error'] == 'hash_already_used': # Already claimed. Don't retry. pass elif result['error'] == 'signature_mismatch': # Signer != payment sender. Sign with the same key. pass elif 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; } }

Hoàn tiền

Nếu ủy quyền năng lượng thất bại sau khi thanh toán được xác minh, hoàn tiền TRX sẽ tự động được xếp hàng và gửi trở lại địa chỉ gửi trên chuỗi. Tìm đối tượng hoàn tiền trong phản hồi lỗi.

Lỗi với hoàn tiền
{ "error": "delegation_failed", "message": "Energy delegation failed. Your payment will be refunded.", "ref": "nrg_d_43", "refund": { "type": "queued", "to": "TSenderAddress", "amount": 4 } }

Ví Dụ Hoàn Chỉnh

Toàn bộ quy trình từ đầu đến cuối: gửi TRX, ký, yêu cầu với thử lại. Sao chép và chạy.

const API = 'https://api.tronnrg.com'; const ADDR = 'TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx'; async function rentEnergy(delegateTo, trxAmount = 4) { // 1. Send TRX to the payment address const payment = await tronWeb.trx.sendTransaction(ADDR, trxAmount * 1e6); // 2. Sign: proves you are the sender const 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 = await fetch(`${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 new Error(result.message); await new Promise(r => setTimeout(r, 3000)); } if (result.error) throw new Error(result.message); return result; } // Usage — send any amount between 4 and 1,000 TRX const result = await rentEnergy('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' def rent_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 in range(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': raise Exception(result['message']) time.sleep(3) raise Exception('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']}")
<?php $api = 'https://api.tronnrg.com'; $addr = 'TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx'; function rentEnergy($api, $txHash, $delegateTo, $signature) { // 1. Send TRX to $addr (via iexbase/tron-api) // $payment = $tron->sendTrx($addr, 4); // $txHash = $payment['txid']; // 3. Claim delegation (retry if tx not indexed yet) for ($i = 0; $i < 3; $i++) { $ch = curl_init("${api}/delegate"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_POSTFIELDS => json_encode([ 'tx_hash' => $txHash, 'delegate_to' => $delegateTo, 'signature' => $signature, ]), ]); $result = json_decode(curl_exec($ch), true); curl_close($ch); if (!isset($result['error'])) return $result; if ($result['error'] !== 'payment_verification_failed') throw new Exception($result['message']); sleep(3); } throw new Exception('Transaction not found after retries'); } // Usage $result = rentEnergy($api, $txHash, 'TWalletThatNeedsEnergy'); echo "Delegated: " . $result['energy'] . " energy\n"; echo "Delegation tx: " . $result['delegations'][0]['tx'] . "\n"; echo "Ref: " . $result['ref'] . "\n";
# 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
Telegram WhatsApp