Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions content/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -895,10 +895,10 @@ navigation:
path: wallets/pages/transactions/sponsor-gas/index.mdx
- page: Conditional sponsorship rules
path: wallets/pages/transactions/sponsor-gas/conditional-sponsorship-rules.mdx
- page: Solana sponsorship
path: wallets/pages/transactions/solana/sponsor-gas-solana.mdx
- page: Pay gas with any token
path: wallets/pages/transactions/pay-gas-with-any-token/index.mdx
- page: Solana sponsorship
path: wallets/pages/transactions/sponsor-gas/solana/index.mdx
- section: Swap tokens
collapsed: true
contents:
Expand Down Expand Up @@ -949,6 +949,8 @@ navigation:
path: wallets/pages/third-party/signers/openfort.mdx
- page: Turnkey
path: wallets/pages/third-party/signers/turnkey.mdx
- page: Solana
path: wallets/pages/third-party/signers/solana-signers.mdx
- page: Other signers
path: wallets/pages/third-party/signers/custom-integration.mdx
- section: Account Kit (v4)
Expand Down Expand Up @@ -1050,6 +1052,8 @@ navigation:
path: wallets/pages/low-level-infra/gas-manager/gas-sponsorship/using-sdk/conditional-gas-sponsorship.mdx
- page: Pay Gas with Any ERC20 Token
path: wallets/pages/low-level-infra/gas-manager/gas-sponsorship/using-sdk/pay-gas-with-any-erc20-token.mdx
- page: Solana
path: wallets/pages/transactions/solana/sponsor-gas-solana.mdx
- section: Bundler API
path: wallets/pages/low-level-infra/bundler/overview.mdx
contents:
Expand Down
4 changes: 4 additions & 0 deletions content/redirects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ redirects:
destination: /docs
permanent: true

- source: /docs/wallets/third-party/signers/solana-signers
destination: /docs/wallets/solana/signers
permanent: true

# ========================================= Removed Page Redirects ==========================================
- source: /docs/reference/new-pricing-for-existing-scale-and-growth-customers
destination: /docs/reference/pay-as-you-go-pricing-faq
Expand Down
3 changes: 2 additions & 1 deletion content/wallets/pages/authentication/what-is-a-signer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Here are some important criteria to consider when choosing a signer.

Non-custodial wallet providers store private keys such that they cannot access the private key without the user's involvement. For example, the user must provide a password or passkey that only they know in order to decrypt the private key stored by the provider. Users benefit from heightened security, while remaining in control of their private keys at all times. This is similar to a safety deposit box vault: the provider secures the bank vault but only the user has access to the individual safety deposit boxes (e.g. wallets).


### MPC wallets (non-custodial)

Multi-Party Computation (MPC) providers split the signer account private key into key shares that are then distributed to a number of share holders. Share holders only know the value of their key share and transaction holders can sign transactions without revealing their key shares to other holders.
Expand Down Expand Up @@ -96,6 +95,8 @@ The `SmartWalletClient` accepts any signer that conforms to standard [viem](http

For [EIP-7702](/docs/wallets/transactions/using-eip-7702) delegation, the signer must support `signAuthorization`. See the [third-party signer integration guide](/docs/wallets/third-party/signers/custom-integration) for details on bringing your own signer.

For Solana transactions, use a `SolanaSigner` or one of the [Solana signer adapters](/docs/wallets/solana/signers) from `@alchemy/wallet-apis/solana`.

***

*Disclaimer: This page refers to third-party services, products software, technology, and content (collectively, "Third-Party Services") that may be integrated or interact with Alchemy's software and services. Alchemy is not responsible for any Third-Party Service, or for any compatibility issues, errors, or bugs caused in whole or in part by the Third-Party Service or any update or upgrade thereto. Your use of any Third-Party Service is at your own risk. You are responsible for obtaining any associated licenses and consents to the extent necessary for you to use the Third-Party Services. Your use of the Third-Party Services may be subject to separate terms and conditions set forth by the provider (including disclaimers or warnings), separate fees or charges, or a separate privacy notice. You are responsible for understanding and complying with any such terms or privacy notice.*
2 changes: 1 addition & 1 deletion content/wallets/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Simple APIs to send transactions with advanced capabilities. Gas sponsorship, ba
native currency.
</Card>

<Card title="Solana sponsorship" icon="hand-holding-dollar" href="/docs/wallets/transactions/solana/sponsor-gas">
<Card title="Solana sponsorship" icon="hand-holding-dollar" href="/docs/wallets/transactions/sponsor-gas/solana">
Sponsor fees & rent and say goodbye to "insufficient fees".
</Card>

Expand Down
151 changes: 145 additions & 6 deletions content/wallets/pages/third-party/signers/privy.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Privy
description: Use Privy with Wallet APIs for EIP-7702, sponsorship, and batching
description: Use Privy with Wallet APIs for EIP-7702, Solana, sponsorship, and batching
slug: wallets/third-party/signers/privy
---

Expand All @@ -15,7 +15,7 @@ Upgrade existing Privy wallets to Wallet APIs to enable gasless transactions, ba
<Tab title="React" language="react">
## Setup

Follow these steps to use Privy signers with the Wallet Client SDK.
Follow these steps to use Privy signers with the Wallet Client SDK. EVM and Solana share the same setup; each chain family has its own send-transaction flow below.

### Installation

Expand All @@ -37,6 +37,8 @@ Upgrade existing Privy wallets to Wallet APIs to enable gasless transactions, ba
```
</CodeGroup>

For Solana support, see [Send Solana transactions](#send-solana-transactions) below for the additional peer dependencies.

### Prerequisites: Get your keys (API key, Policy ID, Privy App ID)

* Alchemy API key:
Expand All @@ -52,7 +54,9 @@ Upgrade existing Privy wallets to Wallet APIs to enable gasless transactions, ba
The gas sponsorship policy must be linked to the application behind your Alchemy API key for sponsorship to work.
</Warning>

### 1. Configure PrivyProvider
## Send EVM transactions

### Configure PrivyProvider

Wrap your app with `PrivyProvider` from `@privy-io/react-auth`:

Expand All @@ -78,7 +82,7 @@ Upgrade existing Privy wallets to Wallet APIs to enable gasless transactions, ba
}
```

### 2. Get a signer from Privy
### Get a signer from Privy

Use `toViemAccount` and `useWallets` from `@privy-io/react-auth` to convert a Privy embedded wallet into a viem `LocalAccount`:

Expand All @@ -103,7 +107,7 @@ Upgrade existing Privy wallets to Wallet APIs to enable gasless transactions, ba
};
```

### 3. Handle login
### Handle login

Use `usePrivy` to manage authentication state and conditionally render your wallet UI once the user is logged in:

Expand All @@ -129,7 +133,7 @@ Upgrade existing Privy wallets to Wallet APIs to enable gasless transactions, ba
}
```

### 4. Create the client and send a transaction
### Create the client and send a transaction

Pass the Privy signer to `createSmartWalletClient` and use it to send transactions:

Expand Down Expand Up @@ -174,6 +178,141 @@ Upgrade existing Privy wallets to Wallet APIs to enable gasless transactions, ba

* The client defaults to [EIP-7702](/docs/wallets/transactions/using-eip-7702), which delegates the Privy wallet to a smart wallet at send time. No deployment or wallet migration needed. See the [EIP-7702 guide](/docs/wallets/transactions/using-eip-7702) for non-7702 mode.
* See the [Sponsor gas](/docs/wallets/transactions/sponsor-gas) guide for more on gas sponsorship configuration.

## Send Solana transactions

### Install Solana deps

The example below uses `@solana/kit` and `@solana-program/system` to build the transfer call:

<CodeGroup>
```shell npm
npm install @solana/kit @solana-program/system
```

```shell bun
bun add @solana/kit @solana-program/system
```

```shell yarn
yarn add @solana/kit @solana-program/system
```

```shell pnpm
pnpm add @solana/kit @solana-program/system
```
</CodeGroup>

### Configure PrivyProvider for Solana

Enable Solana embedded wallets in your `PrivyProvider` config:

```tsx
<PrivyProvider
appId="your-privy-app-id"
config={{
embeddedWallets: {
ethereum: { createOnLogin: "all-users" },
solana: { createOnLogin: "all-users" },
showWalletUIs: false,
},
}}
>
<YourApp />
</PrivyProvider>
```

### Send a sponsored Solana transaction

Use `useWallets` from `@privy-io/react-auth/solana` to get the connected Solana wallet. The returned wallet can be passed directly as the Wallet APIs Solana signer.

<CodeBlocks>
```tsx title="SendSponsoredSolanaTransaction.tsx"
import {
alchemyWalletTransport,
createSmartWalletClient,
} from "@alchemy/wallet-apis";
import { useWallets } from "@privy-io/react-auth/solana";
import { useCallback, useMemo } from "react";
import { transferSolCall } from "./utils";

export function SendSponsoredSolanaTransaction() {
const { wallets } = useWallets();
const signer = wallets[0];

const client = useMemo(() => {
if (!signer) return undefined;

return createSmartWalletClient({
transport: alchemyWalletTransport({ apiKey: "YOUR_ALCHEMY_API_KEY" }),
chain: "solana:devnet",
signer,
paymaster: { policyId: "YOUR_SOLANA_POLICY_ID" },
});
}, [signer]);

const handleSend = useCallback(async () => {
if (!client) return;

const { id } = await client.sendCalls({
calls: [
transferSolCall({
from: client.solanaAccount,
to: client.solanaAccount,
lamports: 0n,
}),
],
});

const result = await client.waitForCallsStatus({ id });
console.log("Sponsored Solana transaction status:", result.status);
}, [client]);

return (
<button onClick={handleSend} disabled={!client}>
Send sponsored Solana transaction
</button>
);
}
```

```ts title="utils.ts"
import {
getTransferSolInstructionDataEncoder,
SYSTEM_PROGRAM_ADDRESS,
} from "@solana-program/system";
import { address } from "@solana/kit";
import { bytesToHex } from "viem";

export function transferSolCall(args: {
from: string;
to: string;
lamports: bigint;
}) {
const source = address(args.from);
const destination = address(args.to);
const data = bytesToHex(
getTransferSolInstructionDataEncoder().encode({
amount: args.lamports,
}),
);

return {
programId: SYSTEM_PROGRAM_ADDRESS,
accounts: [
{ pubkey: source, isSigner: true, isWritable: true },
{ pubkey: destination, isSigner: false, isWritable: true },
],
data,
};
}
```
</CodeBlocks>

### Notes

* Solana sponsorship requires a Solana gas sponsorship policy. See [Solana sponsorship](/docs/wallets/transactions/sponsor-gas/solana).
* For non-Privy Solana signer sources (Phantom, `@solana/wallet-adapter-react`, raw keypairs, Wallet Standard), see [Solana signer adapters](/docs/wallets/solana/signers).
</Tab>

<Tab title="JavaScript" language="typescript">
Expand Down
Loading
Loading