Skip to content

[Smart Contract] Pre-flight simulations via Tenderly for every wallet transaction #694

Description

@nanaf6203-bit

Problem Statement

Today, every wallet-driven transaction in TransactionConfirmation.tsx, batchTransaction.ts, and secureTransactionUtils.ts is sent to the chain without a pre-flight simulation. Users learn about a failed transaction only after spending gas.

Acceptance Criteria

  • New simulateTransaction(txRequest) API wraps viem's estimateContractGas and a Tenderly-style simulateApi.tx call
  • Surfaced in the UI as an expandable "Simulated result" section
  • Show top-3 expected state changes (token balance deltas, NFT ownership diffs)
  • Optional opt-out ("Skip simulation for low-value tx")

Implementation Notes

Tenderly API key kept server-side. Front-end posts via /api/simulate. Vitest fetch mocks emulate Tenderly responses.

Files Likely Affected

  • src/utils/tenderlySimulation.ts (new)
  • src/app/api/simulate/route.ts (new)
  • src/components/TransactionConfirmation.tsx
  • src/lib/batchTransaction.ts

Difficulty / Effort

  • Difficulty: Hard
  • Effort: T-Shirt XL

Labels

web3, priority:high, feature, area:smart-contract

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions