> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# evaluateTransaction

> Evaluate a transaction for security risks.

## Function Signature

```dart theme={null}
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

| Parameter              | Type                                     | Required | Description                    |
| ---------------------- | ---------------------------------------- | -------- | ------------------------------ |
| `chainId`              | `String`                                 | Yes      | The chain ID in CAIP-2 format  |
| `to`                   | `String`                                 | Yes      | The recipient/contract address |
| `from`                 | `String`                                 | No       | The sender address             |
| `value`                | `String`                                 | No       | Value in wei (hex string)      |
| `data`                 | `String`                                 | No       | Transaction data (hex string)  |
| `gas`                  | `String`                                 | No       | Gas limit (hex string)         |
| `maxFeePerGas`         | `String`                                 | No       | Max fee per gas (hex string)   |
| `maxPriorityFeePerGas` | `String`                                 | No       | Max priority fee (hex string)  |
| `operationType`        | `PortalEvaluateTransactionOperationType` | No       | Type of evaluation to perform  |

### PortalEvaluateTransactionOperationType

| Value        | Description                            |
| ------------ | -------------------------------------- |
| `validation` | Only validate the transaction          |
| `simulation` | Only simulate the transaction          |
| `all`        | Perform both validation and simulation |

## Returns

**`PortalEvaluateTransactionResult`** - An object containing:

| Property         | Type      | Description                                                     |
| ---------------- | --------- | --------------------------------------------------------------- |
| `result`         | `String?` | The overall assessment (e.g., `Benign`, `Warning`, `Malicious`) |
| `reason`         | `String?` | The reason for the assessment                                   |
| `classification` | `String?` | The classification category of the risk                         |
| `description`    | `String?` | A human-readable description of the findings                    |
| `status`         | `String?` | The status of the evaluation                                    |

## Example

```dart theme={null}
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

| Code                | Description                     |
| ------------------- | ------------------------------- |
| `NOT_INITIALIZED`   | Portal was not initialized      |
| `EVALUATION_FAILED` | The evaluation operation failed |

## Related

* [Evaluate a transaction guide](../guide/evaluate-a-transaction)
