Crea Ordine
POST /v1/orders
Crea un ordine di energia e restituisce un indirizzo di deposito. L'utente deve inviare esattamente amount TRX da address_from a deposit_address per attivare la consegna.
Corpo della richiesta
| Field | Type | Required | Description |
|---|---|---|---|
referral_code | string | no* | Il tuo codice referral. La commissione per questo ordine viene accreditata al suo proprietario. Max 64 caratteri. |
address_from | string | sì | Indirizzo TRON che invierà il pagamento in TRX. |
address_to | string | sì | Indirizzo TRON che riceverà l'energia e il bandwidth. |
resources.duration | integer | sì | Durata del noleggio delle risorse in ore. Deve essere 1. |
resources.energy | integer | no** | Quantità di energia da consegnare. |
resources.bandwidth | integer | no** | Quantità di bandwidth da consegnare. |
address_to_activation | boolean | no | Se true, attiva address_to on-chain. Il valore predefinito è false. |
* Obbligatorio per la commissione partner. Senza un referral_code valido, l'ordine non viene attribuito ad alcun account partner.
** Almeno uno tra resources.energy e resources.bandwidth deve essere maggiore di zero.
Includi sempre referral_code
Passa referral_code in ogni chiamata POST /v1/orders. Un referral_code assente o vuoto significa nessuna commissione guadagnata — anche se l'ordine viene completato con successo.
Esempi
curl -X POST https://api.tronzap.com/v1/orders \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"referral_code": "YOUR_CODE",
"address_from": "TKzxdSv2FZKQrEqkKVgp5DcwEXBEKMg2Ax",
"address_to": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"resources": {
"duration": 1,
"energy": 65000
}
}'const response = await fetch('https://api.tronzap.com/v1/orders', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({
referral_code: 'YOUR_CODE',
address_from: 'TKzxdSv2FZKQrEqkKVgp5DcwEXBEKMg2Ax',
address_to: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
resources: { duration: 1, energy: 65000 },
}),
})
const { result } = await response.json()
// result.deposit_address — send result.amount TRX here
// result.order_id — save for polling$response = file_get_contents('https://api.tronzap.com/v1/orders', false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/json\r\nAccept: application/json",
'content' => json_encode([
'referral_code' => 'YOUR_CODE',
'address_from' => 'TKzxdSv2FZKQrEqkKVgp5DcwEXBEKMg2Ax',
'address_to' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
'resources' => ['duration' => 1, 'energy' => 65000],
]),
],
]));
$data = json_decode($response, true)['result'];
// $data['deposit_address'] — send $data['amount'] TRX hereimport requests
resp = requests.post('https://api.tronzap.com/v1/orders', json={
'referral_code': 'YOUR_CODE',
'address_from': 'TKzxdSv2FZKQrEqkKVgp5DcwEXBEKMg2Ax',
'address_to': 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
'resources': {'duration': 1, 'energy': 65000},
})
result = resp.json()['result']
# result['deposit_address'] — send result['amount'] TRX hereRisposta
{
"code": 0,
"request_id": "550e8400-e29b-41d4-a716-446655440000",
"result": {
"order_id": "01HZX5N6Q9TY3K2P0VWB7HRD4M",
"status": "new",
"deposit_address": "TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7",
"amount": 2.69,
"currency": "TRX",
"expires_at": "2026-05-18T16:07:05+00:00",
"ttl": 3600
}
}Campi della risposta
| Field | Type | Description |
|---|---|---|
order_id | string | ULID dell'ordine creato. Usalo per controllare e annullare. |
status | string | Sempre new per un ordine appena creato. |
deposit_address | string | L'utente deve inviare TRX da address_from a questo indirizzo. |
amount | number | Importo esatto in TRX da inviare. Qualsiasi scostamento non corrisponderà all'ordine. |
currency | string | Sempre TRX. |
expires_at | string | Timestamp ISO-8601. L'ordine passa automaticamente a expired dopo questa data. |
ttl | integer | Secondi rimanenti fino a expires_at. Di solito 3600 (1 ora). |
Importo esatto e mittente richiesti
Il trasferimento TRX deve provenire da address_from ed essere esattamente amount TRX. Qualsiasi altro importo o indirizzo mittente non corrisponderà all'ordine.
