基础 URL: https://api.tronnrg.com 认证: 无需认证。所有端点均为公开。 速率限制: 每 IP 每秒 20 次请求 付款地址: TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx (仅限 API,不适用于手动租用)

工作流程

三个步骤。无需 API 密钥,无需注册,无需连接钱包。所有权通过加密方式证明。

  1. 发送 TRX — 向付款地址发送 4 TRX 或更多。4 TRX = 65,000 能量,8 TRX = 130,000。线性计价。
  2. 签名 — 用发送 TRX 的那个钱包对消息 {tx_hash}:{delegate_to} 签名,以此证明委托由您本人授权。
  3. 领取 — 调用 POST /delegate,附上 tx_hashdelegate_tosignature。能量约 3 秒到账。

付款地址

TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx
仅限 API 的付款地址。 该地址专用于通过 API 的编程集成。请勿用于手动能量租用。手动租用使用另一个地址,见 。tronnrg.com.

向该地址发送 TRX。付款交易的哈希就是触发委托的凭证,每个哈希只能使用一次。

发送 TRX委托能量适用场景
4 TRX65,000向已有钱包的标准 USDT 转账(最低订单)
8 TRX130,000向首次收款方的 USDT 转账
16 TRX260,000一单覆盖四笔标准转账
40 TRX650,000十笔标准转账
100 TRX1,625,000约 25 笔标准转账 — 小型平台的常见规模
1,000 TRX16,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 读取实时值,见下文。

POST /delegate

POST/delegate

领取能量委托。您必须已经向付款地址在链上发送了 TRX。传入交易哈希、接收地址,以及证明您是付款方的签名。

参数类型说明
tx_hashstring必填TRX 付款的 64 位十六进制哈希
delegate_tostring必填接收能量的波场地址
signaturestring必填用 tronWeb.trx.signMessageV2() 对 tronWeb.trx.signMessageV2() 的签名。证明您是付款发送方。
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");
响应 200
{ "ref": "nrg_d_42", "delegate_to": "TWalletAddress", "energy": 65000, "cost": 4, "status": "delegated", "delegations": [ { "tx": "a1b2c3d4e5f6...your delegation tx hash", "energy": 65000 } ] }
字段类型说明
refstringTronNRG 参考 ID。请记录下来以便客服查询。
energynumber委托的总能量
costnumber收取的 TRX
statusstring成功时为 "delegated"
delegationsarray链上委托交易哈希。每个 tx 都可以在 TronScan 上验证。这就是您的收据。

GET /health

GET/health

供监控和可用性工具使用的存活检查。API 进程正常时返回 200 OK。不检查上游节点或供应方。

响应 200
{ "status": "ok" }

错误代码

每个错误响应都包含 error(机器可读、保持稳定)和 message(人类可读)。在代码中请始终以 error 作为分支条件。

代码HTTP含义
invalid_tx_hash400不是 64 位十六进制字符串
invalid_address400不是有效的波场地址
missing_signature400未提供签名
invalid_signature401签名无法验证
signature_mismatch403签名者地址与付款发送方不一致
hash_already_used409该交易哈希已被领取
payment_verification_failed404 / 400付款的链上验证失败。具体原因请读取 message 字段:交易暂未找到(404,几秒后重试)、收款方错误、不是 TRX 转账,或低于 4 TRX 最低额。
delegation_failed400 / 500供应方未能交付能量。如果失败发生在付款验证之后,退款会自动进入队列。出现此错误时请检查 refund 对象。
rate_limited429该 IP 每秒请求过多。上限为每秒 20 次。
server_error500意外的内部错误。请几秒后重试。
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; } }

退款

如果付款验证后委托失败,TRX 退款会自动进入队列,在链上退回发送方地址。请查看错误响应中的 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 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