Buy Energy for a dApp
A complete walkthrough for dApp developers who need TRON energy. From account creation to verifying the delegation on TronScan.
Why Buy Energy
Every transaction on TRON consumes energy. Without delegated energy, your users pay fees in TRX that get burned. For high-volume dApps (token transfers, DEX swaps, contract calls), renting energy through Merx is significantly cheaper than burning TRX - often 3 to 5 times cheaper.
Merx aggregates 7 energy providers and routes your order to the cheapest available source. You interact with one API. If a provider fails, the next cheapest fills your order automatically.
Step 01Register at Merx
Go to merx.exchange and create an account. You will receive a dashboard where you can manage API keys, view orders, and monitor your balance.
Create an API Key
In the dashboard, navigate to API Keys and click Create. You will receive a secret key starting with sk_live_. Copy it immediately -- it will not be shown again. Store it in an environment variable.
export MERX_API_KEY="sk_live_your_key_here"Never hardcode your API key in source code. Use environment variables or a secrets manager.
Deposit TRX
Before placing orders, you need a TRX balance on Merx. Call the deposit endpoint to get your unique deposit address, then send TRX to it from any wallet. Deposits are confirmed after one on-chain confirmation (approximately 3 seconds).
curl https://merx.exchange/api/v1/deposit/info \
-H "X-API-Key: $MERX_API_KEY"{
"address": "TMerxDepositAddressHere",
"network": "TRON",
"min_deposit_sun": 1000000,
"confirmations_required": 1
}Check Current Prices
The prices endpoint is public. It returns live quotes from all active providers, sorted by price. Use it to decide how much energy to buy and for how long.
curl https://merx.exchange/api/v1/pricesFor a quick cost estimate without placing an order, use the preview endpoint. It shows exactly how much TRX you will pay.
curl "https://merx.exchange/api/v1/orders/preview?resource_type=ENERGY&amount=65000&duration_sec=86400" \
-H "X-API-Key: $MERX_API_KEY"Create an Order
Specify the resource type, amount, duration, and the TRON address that should receive the delegation. Include an Idempotency-Key header to prevent duplicate orders on retries.
curl -X POST https://merx.exchange/api/v1/orders \
-H "X-API-Key: $MERX_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: my-dapp-order-001" \
-d '{
"resource_type": "ENERGY",
"amount": 65000,
"duration_sec": 86400,
"target_address": "TYourDAppContractAddress"
}'{
"id": "ord_x7k9m2",
"status": "EXECUTING",
"resource_type": "ENERGY",
"amount": 65000,
"duration_sec": 86400,
"target_address": "TYourDAppContractAddress",
"total_cost_sun": "5460000",
"created_at": "2026-03-29T10:00:00Z"
}Verify on TronScan
Once the order status moves to FILLED, the energy delegation is live on-chain. You can verify it on TronScan by searching for your target address and checking the Resources section. The delegated energy will appear under "Energy (Delegated)".
You can also poll the order endpoint to track status transitions: PENDING, EXECUTING, FILLED, or FAILED.
curl https://merx.exchange/api/v1/orders/ord_x7k9m2 \
-H "X-API-Key: $MERX_API_KEY"Set up a webhook for the order.filled event to get notified automatically instead of polling. See the webhooks guide.
Next Steps
- Automate orders with the JavaScript SDK or Python SDK
- Monitor prices and buy at the best time - see Monitor Prices
- Receive order notifications via webhooks