Overview
ThesimulateTransaction method runs your transaction through a simulated blockchain environment and returns detailed information about what would happen if you executed it.
Transaction simulation requires API registration and whitelist approval. Contact [email protected] to request access.
Benefits
Prevent failures
Detect transaction failures before spending gas on-chain
Estimate gas
Get accurate gas usage estimates for your transactions
Identify risks
Detect interactions with risky or malicious contracts
Preview changes
See exactly what asset changes will occur
How it works
Complete example
Here’s a complete example from the SDK source code:Simulation result
The simulation returns detailed information about the transaction:Success status
Asset changes
TheassetChanges array shows exactly what tokens would be transferred:
Risk detection
The simulation identifies interactions with potentially risky contracts:Common use cases
Validate before execution
Check gas usage
Debug failed transactions
Best practices
Always simulate high-value transactions
Always simulate high-value transactions
For transactions involving significant amounts, always simulate first to detect potential issues before spending gas.
Review asset changes
Review asset changes
Always review the
assetChanges array to ensure you’re sending and receiving the expected amounts.Handle risk warnings
Handle risk warnings
If risks are detected, review them carefully before proceeding.
Error handling
Next steps
Transaction broadcasting
Learn about broadcasting with MEV protection
Gas estimation
Estimate gas limits for your transactions
API reference
View the complete API reference
Error handling
Learn about error handling patterns