모든 오류 응답에는 두 가지 필드가 있습니다. error (기계 판독 가능, 안정적이며 버전 간 변경되지 않음) message (사람이 읽기 쉬운 형식이며, 시간이 지남에 따라 개선될 수 있습니다.) 항상 켜짐으로 설정하세요. error 코드에 표시하세요. message 사용자들에게.

오류 형식

모든 오류 응답은 동일한 구조를 따릅니다.

error response
{ "error": "error_code_here", "message": "Human-readable explanation" }

일부 오류에는 추가 필드가 포함되어 있습니다. ref (위임 시도에 대한 참조 ID) 및 refund (자동 환불에 대한 자세한 내용)

유효성 검사 오류

오류 코드HTTP원인해결
invalid_tx_hash400tx_hash는 64자리의 16진수 문자열이 아닙니다.해시 형식을 확인하세요. 접두사 없이 정확히 64개의 16진수 문자여야 합니다.
invalid_address400delegate_to는 유효한 Tron 주소가 아닙니다.호출하기 전에 TronWeb ()를 사용하여 주소의 유효성을 검사하십시오.
missing_signature400요청서에 서명이 없습니다.메시지에 서명하세요 {tx_hash}:{delegate_to} ~와 함께 tronWeb.trx.signMessageV2() TRX 보낸 지갑에서.
invalid_signature401서명을 확인할 수 없습니다.서명 내용을 정확히 기입했는지 확인하십시오. {tx_hash}:{delegate_to} (소문자 16진수 해시, 콜론, 정확한 Tron 주소).
signature_mismatch403서명자 주소가 송금인 주소와 일치하지 않습니다.서명은 TRX 결제를 보낸 지갑과 동일한 지갑에서 나와야 합니다. 다른 지갑에서 서명을 보내면 결제가 거부됩니다.

결제 오류

오류 코드HTTP원인해결
payment_verification_failed404 / 400온체인 결제를 확인할 수 없습니다. message 해당 항목은 구체적인 원인을 설명합니다.일반적인 원인: 거래가 아직 확인되지 않았습니다(3~5초 기다린 후 다시 시도하세요), 수취인 주소가 잘못되었습니다, 거래가 TRX 이체가 아닙니다, 최소 거래 금액인 4 TRX 미만입니다.
hash_already_used409이 거래 해시는 이미 등록되었습니다.각 결제 해시는 한 번만 사용할 수 있습니다. 새로운 위임을 위해서는 새로운 결제를 보내주세요.

서비스 오류

오류 코드HTTP원인해결
delegation_failed400 / 500공급업체가 에너지 위임을 이행할 수 없었습니다.결제 확인 후 오류가 발생한 경우 자동 환불이 진행됩니다. 확인해 보세요. refund 객체입니다. 그렇지 않으면 다시 시도하거나 지원팀에 문의하십시오. ref ID.
rate_limited429이 IP 주소에서 너무 많은 요청이 들어왔습니다.속도를 늦추고 다시 시도하세요. 초당 요청 수는 20개로 제한됩니다.
server_error500예기치 않은 내부 오류몇 초 후 다시 시도해 주세요. 문제가 지속되면 고객 지원팀에 문의하세요. ref 가능하다면.

코드 오류 처리

recommended error handling
const result = await fetch('https://api.tronnrg.com/delegate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ tx_hash: hash, delegate_to: addr, signature: sig }), }).then(r => r.json()); if (result.error) { switch (result.error) { case 'payment_verification_failed': // Most common: tx not yet indexed. Wait 3s and retry once. await new Promise(r => setTimeout(r, 3000)); return retry(hash, addr); case 'hash_already_used': // Already claimed. Don't retry. throw new Error('Duplicate delegation attempt'); case 'signature_mismatch': // Signer != payment sender. Sign with the same key. throw new Error('Signer does not match payment sender'); case 'delegation_failed': // Refund queued automatically if payment was verified. if (result.refund) console.log('Refund queued:', result.refund); break; default: console.error(result.error, result.message); } return; } // Success console.log('Delegated:', result.energy, 'energy'); console.log('Delegation tx:', result.delegations[0].tx); // verify on TronScan console.log('Ref:', result.ref);
Telegram WhatsApp