| name | transaction-simulator |
| description | Simulate transactions before execution to preview outcomes and detect failures. Save gas and prevent errors. |
Transaction Simulator
When to use this skill
Use this skill BEFORE executing:
- Complex swaps or trades
- Smart contract interactions
- Large transfers
- DeFi operations (stake, lend, etc.)
What It Does
Simulates your transaction on a test environment to show:
- โ
Will it succeed or fail?
- ๐ Expected output amounts
- ๐ฐ Actual gas costs
- โ ๏ธ Warnings and errors
- ๐ State changes preview
NO REAL TRANSACTION IS SENT - It's a safe preview!
Benefits
๐ฐ Save Money
- Avoid failed transactions (still cost gas!)
- Preview slippage before swapping
- Verify gas estimates
๐ก๏ธ Prevent Errors
- Catch insufficient balance
- Detect approval issues
- Identify smart contract bugs
๐ Better Planning
- See exact output amounts
- Preview price impact
- Understand state changes
Usage
from skills.transaction_simulator.scripts.simulate_tx import simulate_transaction
tx_data = {
'from': 'TXXXabc...',
'to': 'SunSwap_Router',
'value': 100,
'data': '...'
}
result = await simulate_transaction(tx_data)
if result['success']:
print(f"Expected output: {result['output_amount']}")
print(f"Gas cost: {result['gas_used']}")
else:
print(f"Would fail: {result['error']}")
Output Example
โ
Successful Simulation
๐ฎ Transaction Simulation
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Operation: Swap 100 TRX โ USDT
Simulation: โ
SUCCESS
Expected Results:
โข Output: 14.85 USDT
โข Price: 1 TRX = 0.1485 USDT
โข Slippage: 0.5%
โข Price Impact: 0.02%
Costs:
โข Gas Used: ~50,000 Energy
โข Est. Fee: 0.15 TRX
โฑ๏ธ Simulation Time: 1.2s
โ
Transaction will succeed
๐ก Proceed with confidence!
โ Failed Simulation
๐ฎ Transaction Simulation
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Operation: Swap 1000 TRX โ SCAM_TOKEN
Simulation: โ FAILED
Error: "Transfer failed - Honeypot detected"
Details:
โข Cannot sell this token after buying
โข Contract has blacklist function
โข Sell tax: 99%
๐จ DO NOT EXECUTE THIS TRANSACTION!
Saved you: ~1000 TRX + gas fees
Technical Details
Simulation Methods
-
TronGrid Simulation API (if available)
- Most accurate
- Uses actual blockchain state
-
Local Fork Simulation
- Creates temporary blockchain fork
- Executes transaction locally
-
Bytecode Analysis
- Analyzes contract code
- Predicts execution flow
Limitations
- โ ๏ธ Simulations use current blockchain state
- ๐ Actual execution may differ if state changes
- ๐ Time-sensitive operations may behave differently
- ๐ Gas estimates are approximate
Integration
Should auto-run before:
- Any swap >$100 USD value
- User's first interaction with a contract
- Transactions to unverified contracts
- User explicitly requests simulation
Safety
โ
100% Safe - No real transactions sent
โ
No costs - Simulation is free
โ
Privacy - Simulations run locally when possible