> ## 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.

# Enhance your wallet security with Blockaid

> Learn how to integrate real-time transaction, address, token, and URL security scanning using Portal's Web SDK with Blockaid.

Portal’s Web SDK integrates with Blockaid to provide real-time security scanning for transactions, addresses, tokens, and URLs. This integration helps detect malicious activity, phishing attempts, scam tokens, and suspicious interactions before users sign or submit transactions.

## Overview

The Blockaid integration enables you to:

* **Scan transactions** before signing or submission (EVM, Solana, Tron)
* **Scan addresses** for known malicious actors or compromised contracts
* **Validate tokens** to detect scams or security risks
* **Verify URLs** to prevent phishing attacks

## Prerequisites

Before using Blockaid security scanning, ensure you have:

* A properly initialized Portal client
* Blockaid integration enabled in your Portal Dashboard (see [Blockaid Integration](../../../integrations/Security/blockaid))

## Scanning EVM Transactions

Use `scanEVMTx` to analyze Ethereum transactions before signing or broadcasting them. This method scans EVM transactions for malicious contract interactions, risky approvals, phishing attempts, and other on-chain security threats.

```typescript theme={null}
async function scanEvmTransaction(portal: Portal) {
  const response = await portal.security.blockaid.scanEVMTx({
    chain: 'eip155:11155111',
    data: {
      from: '0x5e1a0d484c5f0de722e82f9dca3a9d5a421d47cb',
      to: '0x0d524a5b52737c0a02880d5e84f7d20b8d66bfba',
      data: '0x',
      value: '0x1000000000000000',
    },
    account_address: '0x5e1a0d484c5f0de722e82f9dca3a9d5a421d47cb',
  })

  console.log('Blockaid EVM scan response:', response)
}
```

***

## Scanning Solana Transactions

Use `scanSolanaTx` to analyze Solana transactions before signing. This method detects malicious program invocations, suspicious token movements, and other Solana-specific risks.

```typescript theme={null}
async function scanSolanaTransaction(portal: Portal) {
  const response = await portal.security.blockaid.scanSolanaTx({
    encoding: 'base58',
    chain: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
    method: 'signAndSendTransaction',
    options: ['simulation', 'validation'],
    account_address: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY',
    transactions: [
      'vxBNpvao9QJmLKXUThbbjRnxm3ufu4Wku97kHd5a67FDjSqeHwcPrBKTjAHp4ECr61eWwoxvUEVTuuWX65P9bCNDJrTJpX64vjdtpHA8cogA4C92Ubj813wUUA8Ey4Bvcrdj5c1bSTCnwoE8HeFYiyioRLNZTpShx8zkyzXaxkpUvPVRN26363bGvJDNSJt8bihmwAPxfrH7kSV9BvAuhRWsiuUAN4GZzyAiptknHZ1xjzrKAHz68UNJpWnYkaUThye6r3iULZUcp7baBaGAtnUmAdDMGG1UpBusWLF',
    ],
  })

  console.log('Blockaid Solana scan response:', response)
}
```

***

## Scanning Tron Transactions

Use `scanTronTx` to analyze Tron transactions before signing. This method detects malicious smart contract interactions, suspicious token movements, and other Tron-specific security risks.

<Warning>
  `scanTronTx` only supports `tron:mainnet`. Passing any other chain identifier, such as `tron:shasta` or `tron:nile`, throws an error before any request is sent to Blockaid.
</Warning>

```typescript theme={null}
async function scanTronTransaction(portal: Portal) {
  const response = await portal.security.blockaid.scanTronTx({
    chain: 'tron:mainnet',
    account_address: 'TKhJBwsH7hvegxrUHW4oHT5t1BUDds2UG4',
    data: {
      from: 'TKhJBwsH7hvegxrUHW4oHT5t1BUDds2UG4',
      to: 'TMacq4TDUw5q8NFBwmbY4RLXvzvG5JTkvi',
      data: '0xa9059cbb00000000000000000000004102d8b1afe419aaee6ea2a421913b93bc1d5579',
      value: '0x0',
    },
    options: ['simulation', 'validation'],
  })

  console.log('Blockaid Tron scan response:', response)
}
```

The request object accepts the following fields:

| Field             | Type       | Required | Description                                                                                                                                                                                                                                                |
| ----------------- | ---------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chain`           | `string`   | Yes      | Must be `tron:mainnet`. Any other value throws an error.                                                                                                                                                                                                   |
| `account_address` | `string`   | No       | Address initiating the transaction (Base58 format, starts with `T`). Defaults to your Portal client's TRON address when omitted; the request fails if neither is available.                                                                                |
| `data.from`       | `string`   | No       | Sender address (Base58 format). Defaults to the resolved `account_address` when omitted.                                                                                                                                                                   |
| `data.to`         | `string`   | No       | Recipient address (Base58 format)                                                                                                                                                                                                                          |
| `data.data`       | `string`   | No       | Encoded contract call data (hex)                                                                                                                                                                                                                           |
| `data.value`      | `string`   | No       | Amount to transfer, in sun (hex). 1 TRX = 1,000,000 sun.                                                                                                                                                                                                   |
| `metadata`        | `object`   | No       | Dapp (`{ domain }`) or non-dapp (`{ non_dapp }`) context for the transaction. Only applied as-is when provided — if you're scanning on behalf of a dApp, set `domain` explicitly, since a default domain is used only when `metadata` is omitted entirely. |
| `options`         | `string[]` | No       | Analysis types to run: `'simulation'`, `'validation'`, or both                                                                                                                                                                                             |

### Reading the response

Like `scanEVMTx`, the `scanTronTx` result is nested under `data.rawResponse`:

```typescript theme={null}
const rawResponse = response.data?.rawResponse

if (rawResponse?.validation?.result_type === 'Malicious') {
  console.error('Transaction flagged as malicious:', rawResponse.validation)
  return
}

if (rawResponse?.validation?.result_type === 'Warning') {
  // Optionally prompt the user to confirm before proceeding
}

// Safe to proceed with signing
```

`data.rawResponse` can include:

| Field             | Description                                                                                                                             |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `validation`      | `result_type` (`Benign`, `Warning`, or `Malicious`), plus `classification`, `description`, `reason`, `status`, and a list of `features` |
| `simulation`      | Simulated effects of the transaction, returned when `'simulation'` is included in `options`                                             |
| `events`          | Contract events emitted during simulation, when available                                                                               |
| `gas_estimation`  | Estimated gas usage for the transaction, when available                                                                                 |
| `features`        | Additional Blockaid-detected features for the transaction, when available                                                               |
| `block`           | Block associated with the scan                                                                                                          |
| `chain`           | Echoes back the requested chain (`tron:mainnet`)                                                                                        |
| `account_address` | Echoes back the requested `account_address`, when provided                                                                              |

### Error handling

* Passing a `chain` other than `tron:mainnet` rejects immediately with an error and does not send a request to Blockaid.
* Requests with an invalid or incomplete payload, or failures from the Blockaid API itself, reject with the error returned by Blockaid.

***

## Scanning Addresses

Use `scanAddress` to analyze a single address for known security risks. This method can be used for both EVM and Solana addresses and detects malicious contracts, compromised wallets, sanctioned addresses, and other flagged entities.

### EVM Address Scan

```typescript theme={null}
async function scanEvmAddress(portal: Portal) {
  const response = await portal.security.blockaid.scanAddress({
    chain: 'eip155:1',
    address: '0x31c05d73f2333b5a176cfdbb7c5ef96ec7bb04ac',
  })

  console.log('Blockaid EVM address scan response:', response)
}
```

### Solana Address Scan

```typescript theme={null}
async function scanSolanaAddress(portal: Portal) {
  const response = await portal.security.blockaid.scanAddress({
    chain: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
    address: 'BBQUMqaFELxTFh8r1xSttYMHX6ZKzLWhsmGod2vuxgEc',
  })

  console.log('Blockaid Solana address scan response:', response)
}
```

***

## Scanning Tokens

Use `scanTokens` to analyze multiple tokens in a single request for known security risks. This method detects scam tokens, honeypots, compromised contracts, and other malicious token behavior.

```typescript theme={null}
async function scanTokens(portal: Portal) {
  const response = await portal.security.blockaid.scanTokens({
    chain: 'eip155:1',
    tokens: [
      '0x66587563e933bbf3974b89156b47bb82b921eb35',
      '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
    ],
  })

  console.log('Blockaid token scan response:', response)
}
```

***

## Scanning URLs

Use `scanURL` to detect phishing sites and malicious domains before users navigate to them. This method helps protect users from social engineering attacks and malicious off-chain activity.

```typescript theme={null}
async function scanURL(portal: Portal) {
  const response = await portal.security.blockaid.scanURL({
    url: 'https://www.google.com',
  })

  console.log('Blockaid URL scan response:', response)
}
```

***

## Next Steps

* Learn about [signing transactions](./sign-a-transaction)
* Explore [transaction simulation](./simulate-a-transaction)
* Review [Portal API methods](./portal-api-methods)
* Check out the [Blockaid Integration setup](../../../integrations/Security/blockaid)
