Use the correct request sequence
Estimate the address and recommended resource amount first. Request a quote and show the final price. On confirmation, create the order with a unique idempotency key, store its ID and query status until final.
- Estimate: address state and resource profile.
- Quote: current price without a charge.
- Create order: atomic balance charge and delivery start.
- Order status: final result and actual charged total.
Prevent duplicate charges
A network timeout does not prove the server rejected the order. Retrying with a new key can create a duplicate. Reuse the same idempotency key, persist the platform order ID and apply bounded exponential backoff.
Protect credentials and handle errors
Keep the API key on your server, never in browser code, mobile apps or public repositories. Validate HTTP and machine-readable error codes, redact tokens from logs and avoid exposing internal details. Refresh the quote after price_changed and request wallet activation after inactive_address.
FAQ
Is expectedTotalPriceTrx required?
No. It is an optional strict limit for rejecting an order if price changes after the quote.
What should I do after a create-order timeout?
Retry with the same idempotency key or query the stored order. Never generate a new key blindly.
Can an API key be stored in frontend code?
No. Users can extract it from a browser or app. Send requests through your secured backend.
Sources
Technical facts are checked against official TRON documentation. Resource use can change with network and contract state.
EZ Energy API ↗HTTP idempotency ↗