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

# prepareDepositWithPermitTxData

> Prepare transaction data for a gasless permit-based deposit

Prepares transaction data for a deposit using an EIP-2612 permit signature. This enables single-transaction deposits without a separate approval step.

<Info>
  For most use cases, use the [unified deposit workflow](/v0.3.0/intro/products/earn/developers/api/deposit-workflow) which handles authorization automatically.
</Info>

## Import

```ts theme={null}
import { prepareDepositWithPermitTxData } from "@paxoslabs/amplify-sdk";
```

## Usage

```ts theme={null}
const txData = await prepareDepositWithPermitTxData({
  yieldType: YieldType.CORE,
  depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  depositAmount: "1000",
  to: "0x...",
  chainId: 1,
  signature: "0x...", // From wallet signing
  deadline: 1234567890n,
});
```

## Parameters

| Parameter       | Type        | Required | Description                                             |
| --------------- | ----------- | -------- | ------------------------------------------------------- |
| `yieldType`     | `YieldType` | Yes      | Yield strategy type (`CORE`, `TREASURY`, or `FRONTIER`) |
| `depositAsset`  | `Address`   | Yes      | Token contract address to deposit                       |
| `depositAmount` | `string`    | Yes      | Amount to deposit as decimal string (e.g., `"100.50"`)  |
| `to`            | `Address`   | Yes      | Recipient address for vault shares                      |
| `chainId`       | `number`    | Yes      | Blockchain network ID                                   |
| `signature`     | `Hex`       | Yes      | Permit signature from wallet signing                    |
| `deadline`      | `bigint`    | Yes      | Permit deadline (must match signed deadline)            |
| `slippage`      | `number`    | No       | Slippage tolerance in basis points (default: 50)        |
| `partnerCode`   | `string`    | No       | Partner code for fee attribution                        |

```ts theme={null}
interface PrepareDepositWithPermitParams {
  /** Yield strategy type (e.g., YieldType.CORE) */
  yieldType: YieldType;
  /** Token contract address to deposit */
  depositAsset: Address;
  /** Amount to deposit as decimal string */
  depositAmount: string;
  /** Recipient address for vault shares */
  to: Address;
  /** Blockchain network ID */
  chainId: number;
  /** Permit signature (hex string from wallet signing) */
  signature: Hex;
  /** Permit deadline (must match signature deadline) */
  deadline: bigint;
  /** Slippage in basis points (default: 50 = 0.5%) */
  slippage?: number;
  /** Partner code for fee attribution */
  partnerCode?: string;
}
```

## Return Type

<Tabs>
  <Tab title="Type Definition">
    ```ts theme={null}
    interface PermitDepositTxData {
      /** Depositor contract address */
      address: Address;
      /** Chain ID for the transaction */
      chainId: number;
      /** Transaction data */
      data: {
        /** Contract ABI */
        abi: Abi;
        /** Function name to call */
        functionName: string;
        /** Encoded function arguments */
        args: unknown[];
      };
    }
    ```
  </Tab>

  <Tab title="Example Response">
    ```ts theme={null}
    {
      address: "0x1234...5678",
      chainId: 1,
      data: {
        abi: [...], // Depositor ABI
        functionName: "depositWithPermit",
        args: [
          "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // asset
          1000000000n, // amount
          "0xUser...Address", // recipient
          995000000n, // minShares
          1234567890n, // deadline
          28, // v
          "0x...", // r
          "0x...", // s
        ],
      },
    }
    ```
  </Tab>
</Tabs>

## Examples

<Tabs>
  <Tab title="Privy">
    ```tsx theme={null}
    import { encodeFunctionData } from "viem";
    import { usePrivy, useWallets } from "@privy-io/react-auth";
    import {
      prepareDepositAuthorization,
      prepareDepositWithPermitTxData,
      isPermitAuth,
      YieldType,
    } from "@paxoslabs/amplify-sdk";

    const { sendTransaction } = usePrivy();
    const { wallets } = useWallets();
    const wallet = wallets[0];
    const owner = wallet.address as `0x${string}`;

    const params = {
      yieldType: YieldType.CORE,
      depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" as const,
      depositAmount: "1000",
      to: owner,
      chainId: 1,
    };

    // Step 1: Get permit data
    const auth = await prepareDepositAuthorization(params);

    if (isPermitAuth(auth)) {
      // Step 2: Sign the permit
      const provider = await wallet.getEthereumProvider();
      const signature = await provider.request({
        method: "eth_signTypedData_v4",
        params: [owner, JSON.stringify(auth.permitData)],
      }) as `0x${string}`;

      // Step 3: Execute deposit with permit
      const txData = await prepareDepositWithPermitTxData({
        ...params,
        signature,
        deadline: BigInt(auth.permitData.message.deadline),
      });

      await sendTransaction({
        chainId: txData.chainId,
        to: txData.address,
        data: encodeFunctionData({
          abi: txData.data.abi,
          functionName: txData.data.functionName,
          args: txData.data.args,
        }),
      });
    }
    ```
  </Tab>

  <Tab title="Wagmi">
    ```tsx theme={null}
    import { useAccount, useWriteContract, useSignTypedData } from "wagmi";
    import {
      prepareDepositAuthorization,
      prepareDepositWithPermitTxData,
      isPermitAuth,
      YieldType,
    } from "@paxoslabs/amplify-sdk";

    const { address, chainId } = useAccount();
    const { writeContractAsync } = useWriteContract();
    const { signTypedDataAsync } = useSignTypedData();

    const params = {
      yieldType: YieldType.CORE,
      depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" as const,
      depositAmount: "1000",
      to: address!,
      chainId: chainId!,
    };

    const auth = await prepareDepositAuthorization(params);

    if (isPermitAuth(auth)) {
      const signature = await signTypedDataAsync(auth.permitData);

      const txData = await prepareDepositWithPermitTxData({
        ...params,
        signature,
        deadline: BigInt(auth.permitData.message.deadline),
      });

      await writeContractAsync({
        address: txData.address,
        abi: txData.data.abi,
        functionName: txData.data.functionName,
        args: txData.data.args,
        account: address,
      });
    }
    ```
  </Tab>

  <Tab title="Viem">
    ```ts theme={null}
    import { createWalletClient, custom } from "viem";
    import { mainnet } from "viem/chains";
    import {
      prepareDepositAuthorization,
      prepareDepositWithPermitTxData,
      isPermitAuth,
      YieldType,
    } from "@paxoslabs/amplify-sdk";

    const client = createWalletClient({
      account,
      chain: mainnet,
      transport: custom(window.ethereum),
    });

    const params = {
      yieldType: YieldType.CORE,
      depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" as const,
      depositAmount: "1000",
      to: account,
      chainId: mainnet.id,
    };

    const auth = await prepareDepositAuthorization(params);

    if (isPermitAuth(auth)) {
      const signature = await client.signTypedData({
        account,
        ...auth.permitData,
      });

      const txData = await prepareDepositWithPermitTxData({
        ...params,
        signature,
        deadline: BigInt(auth.permitData.message.deadline),
      });

      await client.writeContract({
        address: txData.address,
        abi: txData.data.abi,
        functionName: txData.data.functionName,
        args: txData.data.args,
        account,
      });
    }
    ```
  </Tab>
</Tabs>

## Permit Support

Not all tokens support EIP-2612 permits. Use `prepareDepositAuthorization()` to check:

| Token | Supports Permit |
| ----- | --------------- |
| USDC  | Yes             |
| USDG  | Yes             |
| pyUSD | Yes             |
| USDT  | **No**          |

<Warning>
  Smart contract wallets (like Privy Smart Wallets or Safe) cannot sign permits. Use the approval flow with transaction batching instead.
</Warning>

## Error Handling

| Error Code             | Description                    | Resolution                              |
| ---------------------- | ------------------------------ | --------------------------------------- |
| `SDK_NOT_INITIALIZED`  | SDK not initialized            | Call `initAmplifySDK()` first           |
| `PERMIT_NOT_SUPPORTED` | Token doesn't support EIP-2612 | Use approval flow instead               |
| `INVALID_SIGNATURE`    | Signature verification failed  | Re-sign with correct data               |
| `DEADLINE_EXPIRED`     | Permit deadline has passed     | Generate new permit with fresh deadline |

## Related

* [Deposit Workflow](/v0.3.0/intro/products/earn/developers/api/deposit-workflow) - Unified deposit API
* [prepareDepositTxData](/v0.3.0/intro/products/earn/developers/api/prepareDepositTxData) - Standard deposits
* [DepositAuthMethod](/v0.3.0/intro/products/earn/developers/types/DepositAuthMethod) - Authorization types
