개발자 문서
API 참조
TronEnergy Energy 위임에 대한 전체 REST API 문서입니다. 엔드포인트, 매개변수, 응답 형식 및 오류 코드가 포함되어 있습니다.
기본 URL:
https://api.tronnrg.com
인증: 필수 사항이 아닙니다. 모든 엔드포인트는 공개되어 있습니다.
속도 제한: IP 주소당 초당 20개 요청
결제 주소: TFqUiCu1JwLHHnBNeaaVKH7Csm4aA3YhZx ( 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 | 한 주문에 표준 이송 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입니다. 지원 문의 시 이 정보를 기록해 두십시오. |
| 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 구체적인 원인에 대한 필드: 아직 tx를 찾을 수 없음(404, 몇 초 후 재시도), 잘못된 수신자, TRX 전송이 아니거나 최소 4 TRX 미만입니다. |
delegation_failed | 400 / 500 | 공급업체가 에너지를 공급할 수 없었습니다. 결제 확인 후 오류가 발생한 경우, 환불이 자동으로 처리됩니다. 자세한 내용은 다음을 확인하세요. refund 이런 일이 발생할 때 객체가 됩니다. |
rate_limited | 429 | 이 IP 주소에서 초당 요청 수가 너무 많습니다. 제한은 초당 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