Code Examples

End-to-end, copy-paste code examples for buying and extending Energy and Bandwidth through the TronSave API.

These pages contain complete, runnable scripts that walk through a full TronSave integration end to end β€” from building and signing a transaction to placing an order and confirming it was filled. Each example is self-contained: copy it, set your credentials, and run it.

The examples come in two flavors:

  • API Key β€” authenticate with a TronSave API Key. Best for backend services that pay from a prepaid TronSave balance. See Authentication.

  • Private Key β€” sign and pay directly from a TRON account using its private key, no prepaid balance required.

All examples use TronWeb 5.3.2. Install it with:

Read more in the TronWeb 5.3.2 release notes.

v2 (current)

Use these examples for new integrations. They target the current TronSave API.

Example

Auth

Description

API Key

Estimate cost and place a resource order paying from your TronSave balance.

Private Key

Sign and pay for a resource order directly from a TRON account.

API Key

Extend an active delegation, paying from your TronSave balance.

Private Key

Extend an active delegation, signing and paying from a TRON account.

v0 (legacy)

Example

Auth

Description

API Key

Legacy flow for buying Energy paying from your TronSave balance.

Private Key

Legacy flow for buying Energy signing from a TRON account.

API Key

Legacy flow for extending an active delegation with an API Key.

Next steps

  • Quickstart β€” the shortest path to your first order.

  • API Reference β€” every endpoint these examples call.

  • SDK (TypeScript, Rust, Python, Java, PHP) β€” a typed wrapper if you prefer not to call the HTTP API directly.

Last updated