Skip to content

Conversation

@alanhungyl
Copy link
Collaborator

⚒️ Add Foundry Simulate: Local blockchain transaction simulation

🎯 Overview

Implemented a new Foundry Simulate feature that generates cast call commands for local blockchain transaction simulation, providing an alternative to Tenderly's cloud-based simulation.

✨ New Features

🔧 Foundry Integration

  • Foundry Cast Command Generator: Automatically generates cast call commands with proper parameters
  • Local Simulation Support: Enables developers to simulate transactions locally using Foundry toolkit
  • Trace Integration: Includes --trace flag for detailed execution traces

🎛️ Dual Simulation Options

  • Tab-based Interface: Added tabbed navigation between Foundry and Tenderly simulation methods
  • Foundry Tab: Local simulation using Foundry's cast call command
  • Tenderly Tab: Existing cloud-based simulation via Tenderly API

📋 Comprehensive Form Fields

  • From Address: Transaction sender address (required)
  • To Address: Target contract address (required)
  • Calldata: Transaction calldata (required)
  • RPC URL: Blockchain RPC endpoint with preset options (required)
  • MSG Value: Optional ETH value in Ether (auto-converts to Wei)
  • Block Height: Optional block number for historical simulation

🌐 Multi-Network Support

  • Preset RPC URLs: Ethereum, BSC, Base, Arbitrum, Avalanche, X Layer
  • Custom RPC Support: Ability to specify custom RPC endpoints
  • Chain Detection: Automatic chain ID detection from RPC URLs

🔧 Technical Implementation

Command Generation Logic

cast call <contract_address> "<calldata>" \
  --from <sender_address> \
  --rpc-url <rpc_endpoint> \
  --value <wei_amount> \
  --block <block_number> \
  --trace

Smart Defaults

  • Trace Enabled: Always includes --trace for detailed execution information
  • Wei Conversion: Automatically converts ETH values to Wei format
  • Block Handling: Supports both latest block and historical block simulation
  • Validation: Comprehensive form validation for required fields

State Management

  • Persistent State: Form data persists when switching between tabs
  • Cross-tab Integration: Seamless workflow from Encode → Simulate
  • Local Storage: Remembers user preferences and settings

🎨 User Experience

Workflow Integration

  1. Encode Calldata → Generate transaction calldata
  2. Click "Simulate" → Auto-navigate to Simulate tab with calldata populated
  3. Choose Method: Select between Foundry (local) or Tenderly (cloud)
  4. Configure & Generate: Fill parameters and generate command/simulate

📁 Files Added/Modified

  • src/components/simulate/SimulateTX.js - Main simulation component with dual tabs
  • src/components/simulate/SimulateFoundry.js - Foundry-specific simulation logic
  • src/components/simulate/SimulateTenderly.js - Tenderly-specific simulation logic
  • src/utils/networkConfig.js - Network and RPC configuration
  • src/App.js - Integration with main application flow
  • src/App.css - Styling for simulation tabs and components

… enhancements

- Added a new simulation tab to the application, allowing users to generate Foundry commands based on input parameters.
- Introduced state management for active tab selection and persisted it in localStorage.
- Enhanced the UI with new components for displaying results and simulating transactions.
- Updated EncodeCalldata and ResultDisplay components to support simulation functionality.
- Improved styling and organization of CSS for better readability and maintainability.
- Added network configuration utilities for managing blockchain networks and RPC endpoints.
- Moved SimulateTX component to a dedicated directory and updated its structure for better organization.
- Introduced SimulateFoundry and SimulateTenderly components to handle specific simulation logic for each service.
- Updated App.js to import SimulateTX from the new location, ensuring proper functionality.
- Enhanced .gitignore to exclude build and distribution directories.
- Removed the old SimulateTX component to streamline the codebase and avoid redundancy.
@alanhungyl alanhungyl closed this Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants