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

# Privy Tutorial

> A tutorial on how to use Privy with the Glider API

The Glider API is wallet agnostic. This means that as long as you can get an [EIP-191 signature](https://eips.ethereum.org/EIPS/eip-191) from the EOA that will own the portfolio, you can use the Glider API.

If you've followed along with the [Quickstart](/quickstart) guide you will notice there's two cases where your wallet architecture will need to interface with Glider. The first is when you're creating a portfolio, and the second is when you're funding a portfolio.

## Creating a Portfolio with Privy

During the [Portfolio Creation](/guides/portfolio-creation) process, an [EIP-191](https://eips.ethereum.org/EIPS/eip-191) signature is required to authenticate ownership of the portfolio and provide Glider access to manage the assets within the portfolio.

<Steps titleSize="h3">
  <Step title="Get the Message to Sign">
    Fetch the data to be signed by calling the `https://api.glider.fi/v1/portfolio/create/signature` endpoint.

    ```javascript theme={null}
    // First, get the message to sign
    const signDataResponse = await fetch(
      `https://api.glider.fi/strategies/sign-data/${strategy.strategyId}`,
      {
        method: "GET",
        headers: {
          "X-API-KEY": "your_api_key_here",
        },
      }
    );

    const signData = await signDataResponse.json();
    const messageToSign = signData.message;
    ```
  </Step>

  <Step title="Sign the Message">
    Sign the message with the owner's wallet. Privy provides a tutorial on [signing a message](https://docs.privy.io/wallets/using-wallets/ethereum/sign-a-message) through their SDKs.

    <Note>
      This will likely require end user interaction to complete the signature.
    </Note>

    ```javascript privy.js theme={null}
    import { useSignMessage } from "@privy-io/react-auth";

    const { signMessage } = useSignMessage();

    // Optional UI options
    const uiOptions = {
      title: "You are signing a Glider Session Key",
      description:
        "This message is required to authenticate ownership of the strategy and provide Glider access to manage the assets within the strategy.",
      buttonText: "Sign",
    };

    // Sign the message with the owner's wallet
    const signature = await signMessage(
      {
        message: messageToSign,
      },
      {
        uiOptions,
        address: wallet.address,
      }
    );
    ```
  </Step>
</Steps>

## Funding a Portfolio with Privy

Funding a portfolio is done by sending funds to a portfolio's vault address. Follow along with [Privy's docs](https://docs.privy.io/wallets/using-wallets/ethereum/send-a-transaction) on sending a transaction for your specific situation.

<Steps titleSize="h3">
  <Step title="Get the Portfolio's Vault Address">
    Fetch the portfolio's vault address by calling the `https://api.glider.fi/v1/portfolio/{portfolioId}` endpoint.

    <FetchStrategyDataCodeblock />
  </Step>

  <Step title="Send Funds to the Portfolio's Vault">
    ```javascript theme={null}
    import { useSendTransaction } from "@privy/react-auth";
    import { formatEther } from "viem";

    const { sendTransaction } = useSendTransaction();

    // Send 0.2 ETH to the portfolio's vault address
    sendTransaction({
      to: "0xE3070d3e4309afA3bC9a6b057685743CF42da77C",
      value: formatEther(0.2),
    });
    ```
  </Step>
</Steps>

## EVM Smart Wallets

Privy provides support for EVM smart wallets. However, smart wallets as owners of portfolios are not yet supported by Glider.

## Interfacing with Viem

An alternative to using Privy's SDKs is to use Viem for funding and message signing. Privy provides a tutorial on interfacing with [Viem](https://docs.privy.io/wallets/using-wallets/ethereum/web3-integrations). By creating a [Wallet Client](https://viem.sh/docs/clients/wallet) you'll be able to sign messages and send transactions for the portfolio owner.
