Skip to main content
Portal provides the function portal.api.evaluateTransaction, which gives you insights into what will happen upon executing a transaction. This function can perform transaction simulation, security validation, or both. Here’s how it works:
The operationType parameter determines what type of evaluation is performed. It can be one of the following values:
  • EvaluateTransactionOperationType.SIMULATION: Perform transaction simulation only
  • EvaluateTransactionOperationType.VALIDATION: Perform security validation only
  • EvaluateTransactionOperationType.ALL: Perform both validation and simulation
This function returns a BlockaidValidateTrxRes containing:
  • simulation: Transaction simulation results. status is always present; the other fields are included when the simulation succeeds:
    • accountAddress: Address being analyzed
    • accountSummary: Summary of account state changes
    • addressDetails: Detailed information about involved addresses
    • assetsDiffs: Asset balance changes, containing:
      • asset: Asset information
      • in: Incoming transfers
      • out: Outgoing transfers
    • exposures: Risk exposure analysis
    • status: Simulation status ('Error' when the simulation fails)
    • error: Why the simulation failed, when it fails
    • totalUsdDiff: Total USD value change
    • totalUsdExposure: Total USD value at risk
  • validation: Security validation results (when operationType is 'VALIDATION' or 'ALL') including:
    • classification: Type of potential security issue
    • description: Detailed description of the validation results
    • features: Array of detected security features
    • reason: Reason for the validation result
    • resultType: Blockaid’s verdict: Benign, Warning, Malicious, or Error. Error means the transaction couldn’t be validated, so treat the result as unverified rather than safe.
    • status: Whether validation succeeded (Success) or errored (Error). This is not the security verdict; use resultType.
    • error: Why validation failed, when resultType is Error
  • chain: Always 'ethereum', since evaluateTransaction evaluates EVM transactions
By incorporating transaction simulations, you can provide your users with a preview of the transaction outcomes and preemptively detect and handle errors, ensuring a smoother user experience.
And now you are evaluating transactions with Portal! 🙌 🚀 Next, we’ll explore how to back up the wallet for recovery if the user loses device access.