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:
operationType parameter determines what type of evaluation is performed. It can be one of the following values:
EvaluateTransactionOperationType.SIMULATION: Perform transaction simulation onlyEvaluateTransactionOperationType.VALIDATION: Perform security validation onlyEvaluateTransactionOperationType.ALL: Perform both validation and simulation
BlockaidValidateTrxRes containing:
- simulation: Transaction simulation results.
statusis 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
operationTypeis'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, orError.Errormeans 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; useresultType. - error: Why validation failed, when
resultTypeisError
- chain: Always
'ethereum', sinceevaluateTransactionevaluates EVM transactions
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.