# Validate Transfers

## Overview

Before sending a payment, you can check whether it would pass the recipient's receive policy. This
lets you surface a clear error to a user up front instead of having the transfer blocked onchain.
Validation reports whether the transfer is authorized and, if not, why it was blocked.

[See the Policy Registry specification](https://docs.tempo.xyz/protocol/tip403/overview)

## Recipes

These recipes assume you have [set up a Tempo client](/tempo).

### Validate a Transfer

Check a prospective transfer with [`receivePolicy.validate`](/tempo/actions/receivePolicy.validate).
It returns `authorized` and a `blockedReason` describing why a transfer would fail.

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const { authorized, blockedReason } = await client.receivePolicy.validate({
  token: '0x20c0000000000000000000000000000000000001',
  sender: '0xcafebabecafebabecafebabecafebabecafebabe',
  receiver: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
})
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

## Best Practices

### Validate Before You Send

Run validation in your payment flow before submitting a transfer so you can show the user a useful
message instead of letting the transfer block onchain. This is especially valuable when paying
unfamiliar recipients.

### Surface the Blocked Reason

The `blockedReason` tells you whether the sender, the token, or the recipient policy caused the
block. Map it to user-facing copy so people understand whether to switch tokens, contact the
recipient, or stop.

### Treat Validation as Advisory

Policies can change between your check and the actual transfer. Validation reduces surprises but is
not a guarantee, so still handle a blocked transfer gracefully at send time.

## See More

<Cards>
  <Card icon="lucide:shield-check" title="Set a Receive Policy" description="Configure the policy that validation checks against." to="/tempo/guides/receive-policies/set" />

  <Card icon="lucide:lock" title="Handle Blocked Funds" description="Recover funds when a transfer is blocked anyway." to="/tempo/guides/receive-policies/blocked" />

  <Card icon="lucide:square-function" title="receivePolicy.validate" description="Check whether a transfer would be authorized." to="/tempo/actions/receivePolicy.validate" />

  <Card icon="lucide:book-open" title="Tempo Docs: Policy Registry" description="Authorization rules for senders, tokens, and recipients." to="https://docs.tempo.xyz/protocol/tip403/overview" />
</Cards>
