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

# Screen transactions before signing

> Check transaction destinations before asking an external wallet to sign.

Use transaction screening to check a transaction before you ask an external wallet to sign it. This is separate from [connect-time screening](https://www.dynamic.xyz/docs/javascript/building-ui/blocked-wallet-screening.md), which runs when a wallet connects and verifies.

## Prerequisites

Before this page:

* Create and initialize a Dynamic client.
* Establish an authenticated session.

## Check whether screening is enabled

Call `isExternalWalletScreeningEnabled()` before screening a transaction. The function returns `true` when the environment has enabled screening for connected-wallet transactions. It requires project settings to be loaded.

```typescript theme={"system"}
import { isExternalWalletScreeningEnabled } from '@dynamic-labs-sdk/client';

if (isExternalWalletScreeningEnabled()) {
  // Screen the transaction before prompting the wallet to sign.
}
```

## Screen a transaction

`screenTransaction` requires an authenticated session and returns a verdict. It does not block a transaction by itself. When the response has a `decision` of `block`, stop your signing flow and show the appropriate experience.

> [tab] JavaScript
>
> ```typescript theme={"system"}
> import {
>   isExternalWalletScreeningEnabled,
>   screenTransaction,
> } from '@dynamic-labs-sdk/client';
>
> async function sendTransaction({ to, transaction, walletClient }) {
>   if (isExternalWalletScreeningEnabled()) {
>     const result = await screenTransaction({
>       chain: 'EVM',
>       context: { evmTransaction: { to } },
>     });
>
>     if (result.decision === 'block') {
>       return;
>     }
>   }
>
>   await walletClient.sendTransaction(transaction);
> }
> ```

> [tab] React
>
> ```tsx theme={"system"}
> import { useScreenTransaction } from '@dynamic-labs-sdk/react-hooks';
>
> function SendButton({ to, transaction, walletClient }) {
>   const { mutateAsync: screen, isPending } = useScreenTransaction();
>
>   const send = async () => {
>     const result = await screen({
>       chain: 'EVM',
>       context: { evmTransaction: { to } },
>     });
>
>     if (result.decision === 'block') {
>       return;
>     }
>
>     await walletClient.sendTransaction(transaction);
>   };
>
>   return (
>     <button type="button" onClick={send} disabled={isPending}>
>       Send
>     </button>
>   );
> }
> ```

### Parameters

| Name | Type | Description |
| - | - | - |
| `chain` | `Chain` | Chain family for the transaction. |
| `context` | `ScreenTransactionRequestContext` | Chain-specific transaction payload. Provide exactly one shape using one of these keys: `btcTransaction`, `evmTransaction`, `stellarTransaction`, `suiTransaction`, `svmTransaction`, or `tronTransaction`. |
| `networkId` | `string \| undefined` | Network within the chain family. Recorded for audit purposes and does not change the verdict. |
| `senderAddress` | `string \| undefined` | Transaction sender. The server screens it alongside destination addresses. |
| `signal` | `AbortSignal \| undefined` | Cancels the request, such as `AbortSignal.timeout(2000)`. |

### Return value

`screenTransaction` returns a `ScreenTransactionResponse`:

| Field | Type | Description |
| - | - | - |
| `decision` | `'allow' \| 'block'` | Whether the transaction passed screening. |
| `action` | `'allow' \| 'alert' \| 'block'` | Screening action for the transaction. |
| `blockedAddresses` | `string[] \| undefined` | Sanctioned addresses that caused a `block` verdict. |
| `sanctionCheckId` | `string \| undefined` | Identifier of the persisted sanction check backing a `block` verdict. |

Undecodable payloads and sanctions-provider errors fail open with an `allow` decision. Other screening failures reject the promise. A `block` verdict resolves normally, so always branch on `decision` before signing.

## Use a chain helper

The chain packages provide helpers that build the screening context for you. They use the same `ScreenTransactionResponse` verdict and do not block by themselves.

Dynamic's [MPC-backed embedded wallets](https://www.dynamic.xyz/docs/embedded-wallets/mpc/overview.md) are screened server-side during signing, so each helper throws `ScreeningNotRequiredError` (exported from `@dynamic-labs-sdk/client`) when you pass an embedded wallet account. Call the helpers only for external wallets.

### EVM

`screenEvmTransactions` accepts:

* `transactions: { to?: string }[]`
* `walletAccount: EvmWalletAccount`
* `networkId?: string`
* `senderAddress?: string`, which defaults to the wallet account address
* `signal?: AbortSignal`

It returns one verdict per transaction in input order. It throws `InvalidParamError` when the wallet account is not an EVM wallet account.

```typescript theme={"system"}
import { isExternalWalletScreeningEnabled } from '@dynamic-labs-sdk/client';
import { screenEvmTransactions } from '@dynamic-labs-sdk/evm';

async function sendEvmTransaction({
  to,
  transaction,
  walletAccount,
  walletClient,
}) {
  if (isExternalWalletScreeningEnabled()) {
    const results = await screenEvmTransactions({
      transactions: [{ to }],
      walletAccount,
    });

    if (results.some(({ decision }) => decision === 'block')) {
      return;
    }
  }

  await walletClient.sendTransaction(transaction);
}
```

### Solana

`screenSolanaTransactions` accepts:

* `transactions: (Transaction | VersionedTransaction)[]`
* `walletAccount: SolanaWalletAccount`
* `senderAddress?: string`, which defaults to the wallet account address
* `signal?: AbortSignal`

It returns one `ScreenTransactionResponse` for the batch. Legacy transactions must already have a recent blockhash and fee payer so they can be serialized for screening. It rejects when a transaction cannot be serialized for screening.

### Bitcoin

`screenBitcoinTransactions` accepts:

* `transactions: { psbt?: string; recipientAddress?: string }[]`
* `walletAccount: BitcoinWalletAccount`
* `networkId?: string`
* `senderAddress?: string`, which defaults to the wallet account address
* `signal?: AbortSignal`

It returns one verdict per transaction in input order. Each transaction must provide a recipient address or an unsigned PSBT. The helper resolves the active network when `networkId` is omitted, and rejects wallet accounts that do not use a Bitcoin provider.

## React hook

`useScreenTransaction` wraps `screenTransaction` as a mutation. Call `mutate` or `mutateAsync` with the same parameters as `screenTransaction`. A `block` verdict is returned in `data`, not thrown as an error.

## See also

* [Handling blocked wallets](https://www.dynamic.xyz/docs/javascript/building-ui/blocked-wallet-screening.md) for connect-time screening during wallet verification
* [Get Wallet Options Catalogue](https://www.dynamic.xyz/docs/javascript/reference/wallets/get-wallet-options-catalogue.md) for choosing external wallets


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.