Skip to content

Transaktionsstatus prüfen

Überprüft den Status einer Transaktion anhand der ID oder externen ID.

POST /v1/transaction/check

Anfrage

Sie müssen entweder eine interne Transaktions-id oder eine external_id angeben.

Anfrage-Parameter

FeldTypErforderlichBeschreibung
idstringNein*Interne Transaktions-ID
external_idstringNein*Externe Transaktions-ID

* Mindestens eine von id oder external_id muss angegeben werden

bash
#!/bin/bash
API_TOKEN="your_api_token"
API_SECRET="your_api_secret"
REQUEST_BODY='{
  "id": "transaction_id"
}'

# Signatur berechnen
SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1)

# API-Anfrage senden
curl -X POST "https://api.tronzap.com/v1/transaction/check" \
  -H "Authorization: Bearer ${API_TOKEN}" \
  -H "X-Signature: ${SIGNATURE}" \
  -H "Content-Type: application/json" \
  -d "${REQUEST_BODY}"
javascript
const crypto = require('crypto');
const axios = require('axios');

const apiToken = 'your_api_token';
const apiSecret = 'your_api_secret';
const requestBody = JSON.stringify({
  id: 'transaction_id'
});

// Signatur berechnen
const signature = crypto
  .createHash('sha256')
  .update(requestBody + apiSecret)
  .digest('hex');

// API-Anfrage senden
axios({
  method: 'post',
  url: 'https://api.tronzap.com/v1/transaction/check',
  headers: {
    'Authorization': `Bearer ${apiToken}`,
    'X-Signature': signature,
    'Content-Type': 'application/json'
  },
  data: requestBody
})
.then(response => console.log(response.data))
.catch(error => console.error(error));
php
<?php
$apiToken = 'your_api_token';
$apiSecret = 'your_api_secret';
$requestBody = json_encode([
  'id' => 'transaction_id'
]);

// Signatur berechnen
$signature = hash('sha256', $requestBody . $apiSecret);

// API-Anfrage senden
$ch = curl_init('https://api.tronzap.com/v1/transaction/check');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Authorization: Bearer ' . $apiToken,
  'X-Signature: ' . $signature,
  'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
python
import hashlib
import json
import requests

api_token = 'your_api_token'
api_secret = 'your_api_secret'
request_body = json.dumps({
  'id': 'transaction_id'
})

# Signatur berechnen
signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest()

# API-Anfrage senden
headers = {
  'Authorization': f'Bearer {api_token}',
  'X-Signature': signature,
  'Content-Type': 'application/json'
}

response = requests.post(
  'https://api.tronzap.com/v1/transaction/check',
  headers=headers,
  data=request_body
)

print(response.json())

Beispiel-Anfrage mit externer ID

bash
#!/bin/bash
API_TOKEN="your_api_token"
API_SECRET="your_api_secret"
REQUEST_BODY='{
  "external_id": "my-external-id-123"
}'

# Signatur berechnen
SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1)

# API-Anfrage senden
curl -X POST "https://api.tronzap.com/v1/transaction/check" \
  -H "Authorization: Bearer ${API_TOKEN}" \
  -H "X-Signature: ${SIGNATURE}" \
  -H "Content-Type: application/json" \
  -d "${REQUEST_BODY}"
javascript
const crypto = require('crypto');
const axios = require('axios');

const apiToken = 'your_api_token';
const apiSecret = 'your_api_secret';
const requestBody = JSON.stringify({
  external_id: 'my-external-id-123'
});

// Signatur berechnen
const signature = crypto
  .createHash('sha256')
  .update(requestBody + apiSecret)
  .digest('hex');

// API-Anfrage senden
axios({
  method: 'post',
  url: 'https://api.tronzap.com/v1/transaction/check',
  headers: {
    'Authorization': `Bearer ${apiToken}`,
    'X-Signature': signature,
    'Content-Type': 'application/json'
  },
  data: requestBody
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

Antwort

Die Antwort liefert den aktuellen Status und Details der Transaktion.

Antwort-Felder

FeldTypBeschreibung
codeintegerAntwortcode (0 = Erfolg)
resultobjectAntwortdaten
result.idstringInterne Transaktions-ID
result.external_idstringExterne Transaktions-ID (falls angegeben)
result.paramsobjectUrsprüngliche Anfrage-Parameter
result.statusstringTransaktionsstatus (siehe Statusliste)
result.amountfloatTransaktionsbetrag
result.created_atstringErstellungszeitstempel (ISO 8601 Format)
result.hashstringTransaktions-Hash (falls abgeschlossen)

Beispiel-Antwort

json
{
    "code": 0,
    "result": {
        "id": "transaction_id",
        "external_id": "my-external-id-123",
        "params": {
            "address": "TRX_ADDRESS",
            "energy_amount": 65000,
            "duration": 1
        },
        "status": "success",
        "amount": 8.25,
        "created_at": "2024-03-22T12:00:00Z",
        "hash": "transaction_hash"
    }
}

Mögliche Fehler

FehlercodeBeschreibung
1Authentifizierungsfehler (falscher Token oder Signatur)
2Ungültiger Service oder Parameter
20Transaktion nicht gefunden
500Interner Server-Fehler

Tron Energy API Documentation