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

# Transfers

# Private Transfers

This guide covers sending tokens privately between privacy addresses using the Privacy Boost WASM SDK.

## Basic Transfer

```typescript theme={null}
const result = await sdk.send({
  tokenAddress: '0x...token-address',
  amount: '250000000000000000', // 0.25 tokens in wei
  recipient: '0x04...recipient-privacy-address', // 194-char privacy address
});
console.log('Transfer TX:', result.txHash);
```

## Transfer Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `tokenAddress` | `string` | Yes | Token contract address |
| `amount` | `string` | Yes | Amount in wei (as string) |
| `recipient` | `string` | Yes | Recipient's 194-character privacy address |

## Transfer Result

```typescript theme={null}
interface TransferResult {
  txHash: string;  // Transaction hash
}
```

## Paying Several Recipients at Once

`sendBatch` pays every recipient from one set of input notes, in a single
request: one fee instead of one per recipient, and one epoch slot instead of
several.

```typescript theme={null}
const result = await sdk.sendBatch({
  tokenAddress: '0x...token-address',
  recipients: [
    { recipient: '0x04...alice', amount: '400000000000000000' },
    { recipient: '0x04...bob', amount: '500000000000000000' },
  ],
});
```

Amounts stay decimal strings, as elsewhere in the WASM API. Output order
follows the array, and the same recipient may appear more than once.

### How many recipients fit

The server proves a fixed set of `(inputs, outputs)` shapes, and a transfer has
to fit inside one of them. Its output count is your recipient count plus a
change note, so a longer recipient list leaves room for fewer input notes:

| Outputs (recipients + change) | Input notes that can be spent |
| - | - |
| 1-2 | up to 15 |
| 3-11 | up to 4 |

So 5 inputs by 3 outputs is not provable, even though 15 inputs and 11 outputs
are each individually fine. In practice: past two recipients, the transfer has
to be coverable by at most four notes. Consolidate fragmented notes first if a
batch is rejected with `UNSUPPORTED_TRANSFER_SHAPE`, or split the payout across
two batches.

## Privacy Address Validation

Always validate the recipient's privacy address before sending:

```typescript theme={null}
if (!sdk.isValidPrivacyAddress(recipient)) {
  console.log('Invalid privacy address');
  return;
}

const result = await sdk.send({ tokenAddress, amount, recipient });
```

## Address Lookup

Look up a user's privacy address by their wallet address:

```typescript theme={null}
const identity = await sdk.resolveIdentity('0x...wallet-address');
console.log('Privacy address:', identity.privacyAddress);

// Send using the resolved privacy address
await sdk.send({
  tokenAddress,
  amount,
  recipient: identity.privacyAddress,
});
```

## Error Handling

```typescript theme={null}
try {
  await sdk.send({ tokenAddress, amount, recipient });
} catch (error) {
  if (error.message.includes('Insufficient balance')) {
    console.log('Not enough shielded balance');
  } else if (error.message.includes('Invalid privacy address')) {
    console.log('Invalid recipient address');
  } else if (error.message.includes('Network error')) {
    console.log('Network error, please retry');
  } else {
    console.log('Transfer failed:', error.message);
  }
}
```

## Best Practices

### 1. Validate Inputs Before Sending

Always validate the privacy address before attempting a transfer.

### 2. Refresh After Transfer

```typescript theme={null}
await sdk.send({ tokenAddress, amount, recipient });
const balance = await sdk.getBalance(tokenAddress);
console.log('Remaining shielded:', balance.shieldedBalance);
```

## Next Steps

* [Deposits Guide](./deposits)
* [Balances Guide](./balances)
* [Transactions Guide](./transactions)
* [Error Handling](./error-handling)


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