開発者向けドキュメント
APIリファレンス
TronEnergy Energy委任に関するREST API完全なドキュメント。エンドポイント、パラメータ、応答形式、およびエラーコードが含まれています。
ベースURL:
https://api.tronnrg.com
認証: 不要です。すべてのエンドポイントは公開されています。
レート制限: IPアドレスあたり毎秒20リクエスト
支払い先住所: TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx ( API専用、手動レンタルには対応していません) 仕組み
たった3ステップ。API APIも、サインアップも、ウォレット接続も不要。所有権は暗号技術によって証明されます。
- TRXを送信 — 支払いアドレスに 4 TRX (またはそれ以上) を送信してください。4 TRX = 65,000 エネルギー。8 TRX = 130,000。線形。
- サイン — メッセージに署名する
{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 | 1回の注文で4つの標準転送 |
| 40 TRX | 650,000 | 10回の標準転送 |
| 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 = await fetch('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 = new HttpClient();
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();
応答200
{
"available": true,
"energy_per_trx": 16250,
"min_order_trx": 4,
"max_order_trx": 1000,
"pay_to": "TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx",
"examples": {
"standard": { "trx": 4, "energy": 65000, "note": "Existing USDT wallet" },
"new_wallet": { "trx": 8, "energy": 130000, "note": "First-time USDT recipient" }
}
}
POST /delegate
POST/delegate
エネルギー委任を申請してください。事前にTRXオンチェーンの支払いアドレスに送金しておく必要があります。トランザクションハッシュ、受取人アドレス、およびあなたが送信者であることを証明する署名を渡してください。
| パラメータ | タイプ | 説明 | |
|---|---|---|---|
| tx_hash | string | 必須 | TRX支払いの64文字の16進数ハッシュ |
| delegate_to | string | 必須 | エネルギーを受け取るためのTronアドレス |
| signature | string | 必須 | 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 }
]
}
| 分野 | タイプ | 説明 |
|---|---|---|
| ref | string | TronNRG参照IDです。サポートに関するお問い合わせの際は、このIDをログに記録してください。 |
| energy | number | 委任された総エネルギー |
| cost | number | TRX充電済み |
| status | string | 成功を「委任」する |
| delegations | array | オンチェーン委任トランザクションハッシュ。 tx 検証可能 TronScanこれが領収書です。 |
GET /health
GET/health
監視ツールと稼働状況ツールのライブネスチェック。 200 OK APIプロセスが起動しているときに実行されます。アップストリームノードやプロバイダはチェックしません。
応答200
{ "status": "ok" }
エラーコード
すべてのエラー応答には error (安定していて、機械可読) message (人間が読める形式)。常にオンにしてください。 error あなたのコードの中で。
| コード | HTTP | 意味 |
|---|---|---|
invalid_tx_hash | 400 | 64文字の16進数文字列ではありません |
invalid_address | 400 | 有効なTronアドレスではありません |
missing_signature | 400 | 署名がありません |
invalid_signature | 401 | 署名を確認できませんでした |
signature_mismatch | 403 | 署名者の住所が支払い送信者と一致しません |
hash_already_used | 409 | トランザクションハッシュは既に取得済みです |
payment_verification_failed | 404 / 400 | 支払いのオンチェーン検証に失敗しました。 message 具体的な原因を示すフィールド: トランザクションがまだ見つかりません (404、数秒後に再試行)、宛先が間違っています、 TRX転送ではありません、または 4 TRX最小額を下回っています。 |
delegation_failed | 400 / 500 | 供給業者がエネルギーを供給できませんでした。支払いが確認された後に障害が発生した場合、返金が自動的にキューに追加されます。 refund この場合、オブジェクトが対象となります。 |
rate_limited | 429 | このIPアドレスからの1秒あたりのリクエスト数が多すぎます。制限は20件/秒です。 |
server_error | 500 | 予期せぬ内部エラーが発生しました。数秒後に再試行してください。 |
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払い戻しが自動的にキューに追加され、オンチェーンの送信者アドレスに送り返されます。エラー応答で払い戻しオブジェクトを確認してください。
返金に関するエラー
{
"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