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

# RelayerClient

> Fee-sponsored transaction submission via a relayer proxy.

## Overview

`RelayerClient` handles communication with a relayer proxy for fee-sponsored transactions. It's created automatically when you pass `relayerUrl` to `SmartAccountKit`, and accessed via `kit.relayer`.

```typescript theme={null}
import { RelayerClient } from 'smart-account-kit';
```

## Via SmartAccountKit (Recommended)

Configure a `relayerUrl` and the SDK handles routing automatically:

```typescript theme={null}
const kit = new SmartAccountKit({
  // ...
  relayerUrl: 'https://my-relayer.example.com',
});

// Uses relayer automatically
await kit.transfer(tokenContract, recipient, amount);

// Bypass relayer for a specific call
await kit.transfer(tokenContract, recipient, amount, { forceMethod: 'rpc' });

// Access client directly
if (kit.relayer) {
  const result = await kit.relayer.sendXdr(signedTx);
}
```

## Direct Usage

```typescript theme={null}
const relayer = new RelayerClient('https://my-relayer.example.com');
```

### `send()`

Submit a transaction via func + auth (for `invokeHostFunction` flows). The relayer wraps it in a fee bump and sponsors fees.

```typescript theme={null}
const result = await relayer.send(
  funcXdr: string,
  authXdrs: string[]
): Promise<RelayerResponse>
```

### `sendXdr()`

Submit a fully signed transaction XDR. Used for deployments and other non-invoke flows.

```typescript theme={null}
const result = await relayer.sendXdr(
  signedTransactionXdr: string
): Promise<RelayerResponse>
```

## Response

```typescript theme={null}
import type { RelayerResponse } from 'smart-account-kit';

interface RelayerResponse {
  success: boolean;
  hash?: string;        // Transaction hash on success
  error?: string;       // Error message on failure
  errorCode?: RelayerErrorCode;
}
```

## Error Codes

```typescript theme={null}
import { RelayerErrorCodes } from 'smart-account-kit';
import type { RelayerErrorCode } from 'smart-account-kit';
```

| Code                | Description                                             |
| ------------------- | ------------------------------------------------------- |
| `NETWORK_ERROR`     | Could not reach the relayer                             |
| `SUBMISSION_FAILED` | Relayer received the request but the transaction failed |
| `INVALID_REQUEST`   | Malformed request                                       |
| `TIMEOUT`           | Relayer did not respond in time                         |
