Skip to main content

Recommended: JavaScript SDK with React Hooks

For new React apps, we recommend the JavaScript SDK with React Hooks (@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.
Dynamic provides React hooks to simulate transactions programmatically without using the built-in UI. These hooks allow you to validate transactions before sending them to the network.

useEVMTransactionSimulation

Use this hook to simulate EVM transactions and get detailed information about the transaction’s expected outcome, including asset transfers, balance changes, and security validations.

Usage

Parameters

The simulateEVMTransaction function accepts an object with the following parameters: The transaction object supports the following fields: Note: The chainId is automatically fetched from the wallet connector and should not be included in the parameters.

Response

The simulation returns a SimulateTransactionResponse object containing:
  • assetTransfers - Array of asset transfers that will occur
  • assetDiffs - Balance changes for each asset
  • blockaidValidation - Security validation results
  • priceData - Price information for assets involved

Example

Simulating contract interactions

Simulating Account Abstraction transactions

For ZeroDev wallets and other account abstraction implementations, use the simulateEVMTransactionAA function:

useSVMTransactionSimulation

Use this hook to simulate Solana (SVM) transactions and validate them before sending to the network.

Usage

Parameters

The simulateSVMTransaction function accepts an object with the following parameters: Note: The hook accepts the Transaction object directly and handles bs58 encoding internally. Do not serialize the transaction to base64.

Response

The simulation returns a SimulateTransactionResponse object containing:
  • assetTransfers - Array of asset transfers that will occur
  • assetDiffs - Balance changes for each asset
  • blockaidValidation - Security validation results
  • priceData - Price information for assets involved

Example

Simulating versioned transactions

Error handling

Both hooks provide error states that you can use to handle simulation failures:

Security validation

The simulation response includes security validation from Blockaid, which helps identify potentially malicious transactions:
Last modified on June 25, 2026