DocumentationBrowse sections

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 compares multiple energy providers and gives you one current executable MERX quote for exact order parameters. The quote identifies the provider represented by the current price; PowerSun fulfills accepted MERX orders.

Step 01

Register 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.

Step 02

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.

Environment variablebash
export MERX_API_KEY="sk_live_your_key_here"
WARNING

Never hardcode your API key in source code. Use environment variables or a secrets manager.

Step 03

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 without a memo. Check your balance after the transfer has been confirmed and credited.

Get deposit addressbash
curl https://merx.exchange/api/v1/deposit/info \
  -H "X-API-Key: $MERX_API_KEY"
Responsejson
{
  "data": {
    "deposit_address": "TYourPersonalDepositAddress...",
    "min_amount_trx": 2,
    "activation_fee_trx": 0,
    "note": "Send TRX to this address without a memo."
  }
}
Step 04

Check Current Prices

The prices endpoint is public. It returns non-executable raw observations from active providers for market analysis. Use the exact preview below when you need the current order price and quoted provider.

Fetch pricesbash
curl https://merx.exchange/api/v1/prices

For a quick cost estimate without placing an order, use the preview endpoint. It shows the current provider and how much TRX you would pay.

Preview order costbash
curl "https://merx.exchange/api/v1/orders/preview?resource=ENERGY&amount=65000&duration=86400&target_address=TYourDAppContractAddress"
Step 05

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. Choose a fixed duration: 2, 5, 10, 15, 30 minutes; 1, 3, 6, or 24 hours.

Place orderbash
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"
  }'
Responsejson
{
  "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"
}
Step 06

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.

Check order statusbash
curl https://merx.exchange/api/v1/orders/ord_x7k9m2 \
  -H "X-API-Key: $MERX_API_KEY"
TIP

Set up a webhook for the order.filled event to get notified automatically instead of polling. See the webhooks guide.

Next Steps