Skip to main content

Function Signature

Future<PortalEvaluateTransactionResult> evaluateTransaction({
  required String chainId,
  required String to,
  String? from,
  String? value,
  String? data,
  String? gas,
  String? maxFeePerGas,
  String? maxPriorityFeePerGas,
  PortalEvaluateTransactionOperationType? operationType,
})

Description

Evaluates a transaction for security risks using Blockaid. This helps identify malicious contracts, phishing attempts, and other security threats before sending a transaction.

Parameters

ParameterTypeRequiredDescription
chainIdStringYesThe chain ID in CAIP-2 format
toStringYesThe recipient/contract address
fromStringNoThe sender address
valueStringNoValue in wei (hex string)
dataStringNoTransaction data (hex string)
gasStringNoGas limit (hex string)
maxFeePerGasStringNoMax fee per gas (hex string)
maxPriorityFeePerGasStringNoMax priority fee (hex string)
operationTypePortalEvaluateTransactionOperationTypeNoType of evaluation to perform

PortalEvaluateTransactionOperationType

ValueDescription
validationOnly validate the transaction
simulationOnly simulate the transaction
allPerform both validation and simulation

Returns

PortalEvaluateTransactionResult - An object containing:
PropertyTypeDescription
resultString?The overall assessment (e.g., Benign, Warning, Malicious)
reasonString?The reason for the assessment
classificationString?The classification category of the risk
descriptionString?A human-readable description of the findings
statusString?The status of the evaluation

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

final result = await portal.evaluateTransaction(
  chainId: 'eip155:1',
  to: '0xContractAddress',
  value: '0x0',
  data: '0xa9059cbb...',
  operationType: PortalEvaluateTransactionOperationType.all,
);

// Check the result
if (result.result == 'Benign') {
  print('Transaction appears safe');
} else if (result.result == 'Warning') {
  print('Proceed with caution');
  print('Classification: ${result.classification}');
  print('Description: ${result.description}');
} else if (result.result == 'Malicious') {
  print('Transaction blocked');
  print('Reason: ${result.reason}');
}

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
EVALUATION_FAILEDThe evaluation operation failed