Simulate a Transaction Before Sending
Broadcasting a failing transaction still burns fees. This guide simulates a raw transaction first so you see balance changes and any revert reason before it hits the network. Simulate on every path where a revert or fee shortfall would cost you.
- An API key with C2 access for the simulate endpoint.
- A built raw transaction from /v1/tx/{chain}/build (or your own encoder).
1Build the transaction
Build a raw payload for the transfer you intend to send. The build endpoint returns the unsigned raw bytes.
curl -X POST https://api.1st-node.com/v1/tx/tron/build \
-H "Authorization: Bearer sk_live_..." \
-d '{"from":"TQ1n7...","to":"TR8h2...","amount":"1000000"}'
> {"raw":"0a02...","fee_estimate":"1100000"}2Simulate the raw transaction
POST the raw payload to /v1/tx/{chain}/simulate. Inspect balance_changes and revert_reason before committing any signature.
curl -X POST https://api.1st-node.com/v1/tx/tron/simulate \
-H "Authorization: Bearer sk_live_..." \
-d '{"raw":"0a02..."}'
> {"success":true,"revert_reason":null,
> "balance_changes":[{"address":"TQ1n7...","delta":"-1000000"}]}3Branch on the result
If success is false, read revert_reason (for example insufficient energy or an ERC-20 allowance) and fix inputs. Only sign and broadcast a clean simulation.
Preguntas frecuentes
What does simulate return on a failing transaction?
success is false and revert_reason carries the decoded cause — a contract revert string, insufficient fee, or missing energy — so you fix it before spending fees.
Is simulation charged the same as a broadcast?
Simulation is a C2 primitive, the same tier as build, sign and broadcast. It runs against a forked state and never touches the mempool.
Sigue leyendo
Recarga, obtén tu clave y publica.
Autoservicio. Paga en cripto o con tarjeta. Medido por créditos: las primitivas pesadas cuestan más, las simples son baratas.
Obtener clave API