diff --git a/.codex/config.toml b/.codex/config.toml new file mode 100644 index 0000000000..55cca93b35 --- /dev/null +++ b/.codex/config.toml @@ -0,0 +1,5 @@ +[mcp_servers.notion] +url = "https://mcp.notion.com/mcp" + +[mcp_servers.slack] +url = "https://mcp.slack.com/sse" diff --git a/SOLANA_DOGFOODING.md b/SOLANA_DOGFOODING.md new file mode 100644 index 0000000000..7d5ab1543d --- /dev/null +++ b/SOLANA_DOGFOODING.md @@ -0,0 +1,822 @@ +# [Wallet APIs] Solana API Spec, SDK Implementation, & Dogfooding Guide + +API shape, real request/response examples, and five runnable demos for Solana smart wallets. + +All examples use the **Alchemy Wallet APIs preview endpoint** on **Solana devnet**. + +--- + +## Prerequisites + +| What | Where to get it | +| ------------------------------------- | ------------------------------------------------------------------------------ | +| **Alchemy API key** | Dashboard — must have Wallet APIs enabled | +| **Solana policy ID** | Gas Manager → create a Solana devnet sponsorship policy | +| **Privy app ID** (Privy example only) | [Privy dashboard](https://dashboard.privy.io) — enable Solana embedded wallets | +| **bun** (CLI examples) | | +| **Node 22+** (React examples) | | + +--- + +## API Shape + +### Common Types + +#### `SolanaChainId` + +``` +"solana:mainnet" | "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" // Mainnet +"solana:devnet" | "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1" // Devnet +``` + +#### `SolanaAddress` + +Base58-encoded string, 32-44 characters. + +#### `SolanaInstruction` + +```jsonc +{ + "programId": SolanaAddress, + "accounts?": [ + { + "pubkey": SolanaAddress, + "isSigner": boolean, + "isWritable": boolean + } + ], + "data": Hex +} +``` + +#### `StatusCode` + +| Code | Title | Description | +| ---- | ---------------- | -------------------------------------------------------------- | +| 100 | Pending | Submitted but not yet confirmed | +| 200 | Confirmed | Included on-chain successfully | +| 400 | Offchain Failure | Not included on-chain, will not retry (e.g. expired blockhash) | +| 500 | Onchain Failure | Reverted completely on-chain | + +> Codes 110, 115, 116, 120, 410, 600 exist in the union but are EVM/cross-chain specific. + +--- + +### wallet_prepareCalls + +#### Request + +```jsonc +{ + "method": "wallet_prepareCalls", + "params": [ + { + "calls": SolanaInstruction[], + "from": SolanaAddress, + "chainId": SolanaChainId, + "addressLookupTableAddresses?": SolanaAddress[], + "capabilities?": { + "paymasterService?": { // enables fee sponsorship + "policyId": string, + "webhookData?": string + } + } + } + ] +} +``` + +#### Response + +```jsonc +{ + "type": "solana-transaction-v0", + "chainId": SolanaChainId, + "signatureRequest": { + "type": "solana_signTransaction", + "data": Hex + }, + "data": { + "compiledTransaction": Hex, + "signer": SolanaAddress, + "version": "0", + "lifetimeConstraint": { + "blockHash": string, + "lastValidBlockHeight?": Hex + } + }, + "feePayment": { + "sponsored": boolean, + "feePayer": SolanaAddress + }, + "details": { + "type": "solana-transaction-v0", + "data": { + "calls": SolanaInstruction[], + "addressLookupTableAddresses?": SolanaAddress[] + } + } +} +``` + +--- + +### wallet_sendPreparedCalls + +#### Request + +```jsonc +{ + "method": "wallet_sendPreparedCalls", + "params": [ + { + "type": "solana-transaction-v0", + "chainId": SolanaChainId, + "data": { + "compiledTransaction": Hex, + "signer": SolanaAddress, + "version": "0", + "lifetimeConstraint": { + "blockHash": string, + "lastValidBlockHeight?": Hex + } + }, + "signature": { + "type": "ed25519", + "data": string + } + } + ] +} +``` + +#### Response + +```jsonc +{ + "id": Hex, + "details": { + "type": "solana-transaction-v0" + } +} +``` + +--- + +### wallet_getCallsStatus + +#### Request + +```jsonc +{ + "method": "wallet_getCallsStatus", + "params": [Hex] +} +``` + +#### Response + +```jsonc +{ + "id": Hex, + "chainId": SolanaChainId, + "atomic": boolean, + "status": StatusCode, + "commitment?": "processed" | "confirmed" | "finalized", + "receipts?": [ + { + "signature": string, + "blockTime?": Hex, + "slot": Hex + } + ] +} +``` + +--- + +### Flow + +``` +1. wallet_prepareCalls → get signatureRequest.data +2. Client signs with Ed25519 +3. wallet_sendPreparedCalls → get id +4. wallet_getCallsStatus(id) → poll until status != 100 +``` + +--- + +### Full Examples (Real Devnet Responses) + +#### wallet_prepareCalls — request + +Sponsored 0-lamport self-transfer via the System Program — simplest possible instruction to exercise the full flow. + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "wallet_prepareCalls", + "params": [ + { + "calls": [ + { + "programId": "11111111111111111111111111111111", + "accounts": [ + { + "pubkey": "J8tXRgztWDQWapi7teAxmpx4cH3caJRfckyCBTdUpU3f", + "isSigner": true, + "isWritable": true + }, + { + "pubkey": "J8tXRgztWDQWapi7teAxmpx4cH3caJRfckyCBTdUpU3f", + "isSigner": false, + "isWritable": true + } + ], + "data": "0x0200000000000000000000000000" + } + ], + "chainId": "solana:devnet", + "from": "J8tXRgztWDQWapi7teAxmpx4cH3caJRfckyCBTdUpU3f", + "capabilities": { + "paymasterService": { + "policyId": "850a7066-30d4-49d8-8672-521319d86f5a" + } + } + } + ] +} +``` + +#### wallet_prepareCalls — response + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "type": "solana-transaction-v0", + "chainId": "solana:devnet", + "signatureRequest": { + "type": "solana_signTransaction", + "data": "0x020784602a94bd4715680f44f4169abf36b4ee37407c6806a737859bc6a5b803221b2826ad5d8d08a30c1ed112fe743976383ddd99a8d3884e94be6b7e2893200d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800200010314f223f56f8a396dc5ca02028ede46d3c78161db1856f9dc5f63791527f89ed0fe9c009ff4130a712570159f1b2f31dd1cb3a1481c3f6469f856baf8f7cb666e0000000000000000000000000000000000000000000000000000000000000000cde22751157e9ad919cbe6676978684fdd2348e686ea363b4e4e608d586cbbc301020201010e020000000000000000000000000000" + }, + "data": { + "compiledTransaction": "0x020784602a94bd4715680f44f4169abf36b4ee37407c6806a737859bc6a5b803221b2826ad5d8d08a30c1ed112fe743976383ddd99a8d3884e94be6b7e2893200d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800200010314f223f56f8a396dc5ca02028ede46d3c78161db1856f9dc5f63791527f89ed0fe9c009ff4130a712570159f1b2f31dd1cb3a1481c3f6469f856baf8f7cb666e0000000000000000000000000000000000000000000000000000000000000000cde22751157e9ad919cbe6676978684fdd2348e686ea363b4e4e608d586cbbc301020201010e020000000000000000000000000000", + "signer": "J8tXRgztWDQWapi7teAxmpx4cH3caJRfckyCBTdUpU3f", + "version": "0", + "lifetimeConstraint": { + "blockHash": "ErgbBnrLVthAKiGoPZ7PFDxPxd9MBqZt2Z6pJbJQeRxN", + "lastValidBlockHeight": "0x1aa23b09" + } + }, + "feePayment": { + "sponsored": true, + "feePayer": "2QmJeMox1MU8X9hqvQj3JqWvYfJcGUYyAgZtTuvKhT3u" + }, + "details": { + "type": "solana-transaction-v0", + "data": { + "calls": [ + { + "programId": "11111111111111111111111111111111", + "accounts": [ + { + "pubkey": "J8tXRgztWDQWapi7teAxmpx4cH3caJRfckyCBTdUpU3f", + "isSigner": true, + "isWritable": true + }, + { + "pubkey": "J8tXRgztWDQWapi7teAxmpx4cH3caJRfckyCBTdUpU3f", + "isSigner": true, + "isWritable": true + } + ], + "data": "0x0200000000000000000000000000" + } + ] + } + } + } +} +``` + +#### wallet_sendPreparedCalls — request + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "wallet_sendPreparedCalls", + "params": [ + { + "type": "solana-transaction-v0", + "chainId": "solana:devnet", + "data": { + "compiledTransaction": "0x029f72cdb1dccd1e56e73241b2a2f87fe994dc7bbe67e992b66b55d0e9a673eb2ee5842f6182c6dc4cce9b0892a903bd4416b09d6f71425831986d287d7deaaf0500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800200010314f223f56f8a396dc5ca02028ede46d3c78161db1856f9dc5f63791527f89ed0d4e5f248a0a5d2cb435cefd313c83468487fce7d2a09edc913f04e9bf15bbb040000000000000000000000000000000000000000000000000000000000000000f7536d1d18a5cc6a94ae7efffcde49598d4e91c0a261d7ee9b516c018b33297101020201010e020000000000000000000000000000", + "signer": "FL4oGUvc8DKrKFpxRCVcWQuC3WGLWDvTQzyqqJxUs7vB", + "version": "0", + "lifetimeConstraint": { + "blockHash": "HeTV4vHkpF4G7anshbvkz2DtUxJtEESZ1AsQuKSFQQxg", + "lastValidBlockHeight": "0x1aa1d340" + } + }, + "signature": { + "type": "ed25519", + "data": "2YYhoCTmPPbbv9sGKPkWYYbth6a46f1atvKHLcE41Tn8WWRNjva1krnWTJNq8iY1dzcAdkHMStSJnzomKrbv6DpM" + } + } + ] +} +``` + +#### wallet_sendPreparedCalls — response + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "id": "0x010300000000000000000000000000000000000000000000000000000000000000679f72cdb1dccd1e56e73241b2a2f87fe994dc7bbe67e992b66b55d0e9a673eb2ee5842f6182c6dc4cce9b0892a903bd4416b09d6f71425831986d287d7deaaf05f7536d1d18a5cc6a94ae7efffcde49598d4e91c0a261d7ee9b516c018b332971", + "details": { + "type": "solana-transaction-v0" + } + } +} +``` + +#### wallet_getCallsStatus — pending + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "id": "0x010300...332971", + "chainId": "solana:devnet", + "atomic": true, + "status": 100 + } +} +``` + +#### wallet_getCallsStatus — confirmed + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "id": "0x010300...332971", + "chainId": "solana:devnet", + "atomic": true, + "status": 200, + "commitment": "confirmed", + "receipts": [ + { + "signature": "4Bu3fdFWRMerLXeumu7yWWFJnTvGyuViDt9Y3tkGUCtEp7XSnKstVxCqqrAQwji87HhvC6WhBksdjLXq19CNsZLx", + "blockTime": "0x69f24c8e", + "slot": "0x1b5af7e1" + } + ] + } +} +``` + +--- + +## SDK Signer Interface: `SolanaSigner` + +The simplest possible interface: + +```ts +interface SolanaSigner { + address: string; + signTransaction(input: { + transaction: Uint8Array; + }): Promise<{ signedTransaction: Uint8Array }>; +} +``` + +Adapters in `@alchemy/wallet-apis/solana` convert various signer sources into this interface: + +| What you have | Adapter | +| ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Privy `useConnectedStandardWallets()` | **None needed** — already a `SolanaSigner` ([example](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/examples/solana-privy/src/app/page.tsx)) | +| `@solana/wallet-adapter-react` `useWallet()` | `fromWalletAdapter({ publicKey, signTransaction })` | +| `window.phantom.solana` (injected provider) | `fromWalletAdapter(provider)` ([example](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/examples/solana-privy/src/app/phantom-raw/page.tsx)) | +| `@solana/kit` `KeyPairSigner` | `fromKitSigner(signer)` ([example](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/packages/wallet-apis/src/__tests__/solana-e2e.ts)) | +| Raw Ed25519 keypair / `@solana/web3.js` v1 `Keypair` | `fromKeypair({ address, signMessage })` ([example](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/packages/wallet-apis/src/__tests__/solana-e2e.ts)) | +| `@wallet-standard/app` (low-level, for library authors) | `fromWalletStandard(wallet, account)` ([example](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/examples/solana-privy/src/app/wallet-standard/page.tsx)) | + +All adapters are verified to produce identical signed transactions in the [signer equivalence test](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/packages/wallet-apis/src/adapters/signerEquivalence.test.ts). + +#### Privy (no adapter needed) + +```ts +import { useConnectedStandardWallets } from "@privy-io/react-auth/solana"; + +const { wallets } = useConnectedStandardWallets(); +const signer = wallets[0]; // already a SolanaSigner +``` + +#### `@solana/wallet-adapter-react` + +```ts +import { useWallet } from "@solana/wallet-adapter-react"; +import { fromWalletAdapter } from "@alchemy/wallet-apis/solana"; + +const wallet = useWallet(); +const signer = fromWalletAdapter(wallet); // needs @solana/web3.js +``` + +#### `window.phantom.solana` + +```ts +import { fromWalletAdapter } from "@alchemy/wallet-apis/solana"; + +const phantom = window.phantom?.solana; +await phantom.connect(); +const signer = fromWalletAdapter(phantom); // same adapter, same shape +``` + +#### `@solana/kit` KeyPairSigner + +```ts +import { generateKeyPairSigner } from "@solana/kit"; +import { fromKitSigner } from "@alchemy/wallet-apis/solana"; + +const kitSigner = await generateKeyPairSigner(); +const signer = fromKitSigner(kitSigner); // needs @solana/kit +``` + +#### Raw Ed25519 keypair + +```ts +import { fromKeypair } from "@alchemy/wallet-apis/solana"; + +const signer = fromKeypair({ + address: base58PublicKey, + signMessage: async (message) => { + return new Uint8Array( + await crypto.subtle.sign("Ed25519", privateKey, message), + ); + }, +}); // no Solana libs needed +``` + +#### `@wallet-standard/app` (low-level, for library authors) + +```ts +import { getWallets } from "@wallet-standard/app"; +import { fromWalletStandard } from "@alchemy/wallet-apis/solana"; + +const wallet = getWallets().get().find(/* has solana:signTransaction */); +const { accounts } = await wallet.features["standard:connect"].connect(); +const account = accounts[0]; + +const signer = fromWalletStandard(wallet, account); +``` + +### Why adapters are needed + +`SolanaSigner` takes `Uint8Array` in and out. But the Solana React ecosystem hasn't caught up to wallet-standard: + +- **`@solana/wallet-adapter-react`** (what ~90% of React devs use) exposes `signTransaction(VersionedTransaction)` — the legacy `@solana/web3.js` v1 API. `fromWalletAdapter` handles the `Uint8Array` ↔ `VersionedTransaction` conversion. +- **Raw wallet-standard** (`@wallet-standard/app`) is a low-level API for library authors, not typical app devs. It requires an `account` param and returns arrays — a shape mismatch, not a serialization mismatch. `fromWalletStandard` handles this. +- **Privy** wraps the wallet-standard wallet internally, so their hook already returns a `SolanaSigner`-compatible object. + +### Import paths + +```ts +// Shared client factory — works for both EVM and Solana +import { + createSmartWalletClient, + alchemyWalletTransport, +} from "@alchemy/wallet-apis"; +import type { SolanaSigner } from "@alchemy/wallet-apis"; + +// Solana-specific actions, adapters, and decorator +import { + fromWalletAdapter, + fromWalletStandard, + fromKitSigner, + fromKeypair, +} from "@alchemy/wallet-apis/solana"; +import { prepareCalls, sendCalls } from "@alchemy/wallet-apis/solana"; +``` + +--- + +## Examples + +### 1. SDK Client E2E ([`solana-e2e.ts`](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/packages/wallet-apis/src/__tests__/solana-e2e.ts)) + +Uses `createSmartWalletClient` from `@alchemy/wallet-apis`. This is the highest-level API — it handles prepare, sign, and send internally. + +#### Simplest example + +```ts +import { generateKeyPairSigner } from "@solana/kit"; +import { fromKitSigner } from "@alchemy/wallet-apis/solana"; +import { + createSmartWalletClient, + alchemyWalletTransport, +} from "@alchemy/wallet-apis"; + +const signer = fromKitSigner(await generateKeyPairSigner()); + +const client = createSmartWalletClient({ + signer, + transport: alchemyWalletTransport({ apiKey: ALCHEMY_API_KEY }), + chain: "solana:devnet", + paymaster: { policyId: SOLANA_POLICY_ID }, +}); + +const { id } = await client.sendCalls({ + calls: [ + /* ... */ + ], +}); +const result = await client.waitForCallsStatus({ id }); +``` + +#### What it tests + +- **`fromKitSigner`** path — `generateKeyPairSigner()` + `fromKitSigner()` +- **`fromKeypair`** path — raw Web Crypto Ed25519 key pair (signs only the transaction message bytes) + +#### Run it + +```bash +ALCHEMY_API_KEY= SOLANA_POLICY_ID= \ + bun packages/wallet-apis/src/__tests__/solana-e2e.ts +``` + +#### What to expect + +The script creates two ephemeral key pairs, sends a sponsored 0-lamport self-transfer for each, and waits for on-chain confirmation. You should see output like: + +``` +Chain: solana:devnet +Policy: + +=== fromKitSigner (@solana/kit) === +Signer: +Sending calls... +Call ID: +Waiting for status... +Status: confirmed (200) +Signature: +fromKitSigner (@solana/kit) passed! + +=== fromKeypair (raw Ed25519) === +Signer: +Sending calls... +Call ID: +Waiting for status... +Status: confirmed (200) +Signature: +fromKeypair (raw Ed25519) passed! + +All tests passed! +``` + +--- + +### 2. Raw JSON-RPC E2E ([`solana-raw-rpc-e2e.ts`](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/packages/wallet-apis/src/__tests__/solana-raw-rpc-e2e.ts)) + +Calls `wallet_prepareCalls`, `wallet_sendPreparedCalls`, and `wallet_getCallsStatus` directly via `fetch`. No SDK client — useful for understanding the wire protocol or building in a language without an SDK. + +#### What it tests + +- **Raw Ed25519 signing** — extracts message bytes from the serialized transaction and signs with Web Crypto +- **@solana/kit signing** — deserializes the transaction, signs with `KeyPairSigner.signTransactions` + +#### Run it + +```bash +ALCHEMY_API_KEY= SOLANA_POLICY_ID= \ + bun packages/wallet-apis/src/__tests__/solana-raw-rpc-e2e.ts +``` + +This script logs **full JSON-RPC request and response bodies** for every call. Use it to see exact payloads. + +#### Zero-dependency signing (any language) + +The raw Ed25519 test shows the minimal signing path — no Solana libraries needed. This is the pattern to follow if you're calling the API from Python, Go, Rust, etc.: + +```ts +// 1. Generate an Ed25519 keypair (Web Crypto, or your language's equivalent) +const keyPair = await crypto.subtle.generateKey("Ed25519", true, ["sign"]); +const rawPublicKey = new Uint8Array( + await crypto.subtle.exportKey("raw", keyPair.publicKey), +); +const address = Base58.fromBytes(rawPublicKey); + +// 2. Call wallet_prepareCalls, get back signatureRequest.data (hex) +const txBytes = hexToBytes(prepareResult.signatureRequest.data); + +// 3. Extract the message bytes from the serialized transaction +const numSigs = txBytes[0]; +const messageBytes = txBytes.slice(1 + numSigs * 64); + +// 4. Sign the message bytes with Ed25519 +const sigBytes = new Uint8Array( + await crypto.subtle.sign("Ed25519", keyPair.privateKey, messageBytes), +); + +// 5. Base58-encode the signature, pass to wallet_sendPreparedCalls +const signatureBase58 = Base58.fromBytes(sigBytes); +``` + +--- + +### 3. Privy + Next.js Example ([`examples/solana-privy/`](https://github.com/alchemyplatform/aa-sdk/tree/jake/v5/sol-examples/examples/solana-privy)) + +A minimal Next.js app that logs in with Privy, creates a Solana embedded wallet, and sends a sponsored transaction through the Alchemy smart wallet. + +#### Setup + +```bash +cd examples/solana-privy + +# Install dependencies +pnpm install + +# Create .env.local with your keys +cp .env.example .env.local +``` + +Fill in `.env.local`: + +``` +NEXT_PUBLIC_PRIVY_APP_ID= +NEXT_PUBLIC_ALCHEMY_API_KEY= +NEXT_PUBLIC_SOLANA_POLICY_ID= +``` + +#### Privy dashboard config + +1. Go to [dashboard.privy.io](https://dashboard.privy.io) and select your app +2. Under **Embedded wallets**, make sure Solana wallets are enabled and set to create on login +3. Under **Login methods**, enable at least email or Google + +#### Run it + +```bash +pnpm dev +``` + +Open [http://localhost:3000](http://localhost:3000). + +#### Walkthrough + +1. Click **Login with Privy** — sign in with email or Google +2. If no Solana wallet exists, click **Create Solana Wallet** +3. Click **Send Sponsored SOL Transfer** — this sends a 0-lamport self-transfer through the Alchemy smart wallet +4. Watch the status area — you should see the call ID, then confirmation with a Solana transaction signature + +#### How the code works + +The Privy wallet (`useConnectedStandardWallets`) returns a wallet-standard `StandardConnect` signer. The SDK's `createSmartWalletClient` accepts this directly: + +```ts +import { useConnectedStandardWallets } from "@privy-io/react-auth/solana"; +import { + createSmartWalletClient, + alchemyWalletTransport, +} from "@alchemy/wallet-apis"; + +const { wallets } = useConnectedStandardWallets(); +const privyWallet = wallets[0]; // already a SolanaSigner + +const client = createSmartWalletClient({ + signer: privyWallet, + transport: alchemyWalletTransport({ + apiKey: ALCHEMY_API_KEY, + url: "https://api.g.alchemypreview.com/v2", + }), + chain: "solana:devnet", + paymaster: { policyId: SOLANA_POLICY_ID }, +}); + +const { id } = await client.sendCalls({ + calls: [ + { + programId: "11111111111111111111111111111111", + accounts: [ + { pubkey: wallet.address, isSigner: true, isWritable: true }, + { pubkey: wallet.address, isSigner: false, isWritable: true }, + ], + data: "0x0200000000000000000000000000", + }, + ], +}); + +const result = await client.waitForCallsStatus({ id }); +``` + +--- + +### 4. Wallet Standard Example ([`/wallet-standard`](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/examples/solana-privy/src/app/wallet-standard/page.tsx)) + +Uses `@wallet-standard/app` to discover any installed Solana wallet (Phantom, Solflare, Backpack, etc.) directly — no Privy, no wallet adapter library. The `fromWalletStandard` adapter wraps the wallet's `solana:signTransaction` feature into a `SolanaSigner`. + +#### Run it + +Same as the Privy example — `pnpm dev` from `examples/solana-privy/`, then open [http://localhost:3000/wallet-standard](http://localhost:3000/wallet-standard). + +#### Walkthrough + +1. The page lists all detected browser wallets. Click **Connect \** +2. Approve the connection in the wallet popup +3. Click **Send Sponsored SOL Transfer** +4. Approve the transaction signing in the wallet popup +5. Watch the status area for confirmation + +#### How the code works + +`getWallets()` from `@wallet-standard/app` discovers wallets that register via the wallet-standard protocol. The `fromWalletStandard` adapter wraps the wallet's `solana:signTransaction` feature — no `VersionedTransaction`, no `@solana/web3.js`: + +```ts +import { getWallets } from "@wallet-standard/app"; +import { fromWalletStandard } from "@alchemy/wallet-apis/solana"; + +const { get, on } = getWallets(); +const solanaWallets = get().filter( + (w) => + "standard:connect" in w.features && "solana:signTransaction" in w.features, +); + +// connect +const { accounts } = await wallet.features["standard:connect"].connect(); +const account = accounts[0]; + +// build signer via adapter +const signer = fromWalletStandard(wallet, account); + +const client = createSmartWalletClient({ + signer, + transport: alchemyWalletTransport({ apiKey, url }), + chain: "solana:devnet", + paymaster: { policyId: SOLANA_POLICY_ID }, +}); +``` + +--- + +### 5. Raw Phantom Example ([`/phantom-raw`](https://github.com/alchemyplatform/aa-sdk/blob/jake/v5/sol-examples/examples/solana-privy/src/app/phantom-raw/page.tsx)) + +Connects directly to `window.phantom.solana` without any wallet adapter library. This is the most minimal integration — useful for understanding what the adapter layer does under the hood. + +#### Prerequisites + +[Phantom](https://phantom.app/) must be installed as a browser extension. + +#### Run it + +Same as the Privy example — `pnpm dev` from `examples/solana-privy/`, then open [http://localhost:3000/phantom-raw](http://localhost:3000/phantom-raw). + +#### Walkthrough + +1. Click **Connect Phantom** — approve the connection in the Phantom popup +2. Click **Send Sponsored SOL Transfer** +3. Approve the transaction signing in the Phantom popup +4. Watch the status area for confirmation + +#### How the code works + +Phantom's injected provider (`window.phantom.solana`) exposes `connect()` and `signTransaction(VersionedTransaction)`. The `fromWalletAdapter` adapter from `@alchemy/wallet-apis/solana` handles the `Uint8Array` ↔ `VersionedTransaction` conversion: + +```ts +import { fromWalletAdapter } from "@alchemy/wallet-apis/solana"; + +const phantom = window.phantom?.solana; +await phantom.connect(); + +const signer = fromWalletAdapter(phantom); +const client = createSmartWalletClient({ signer, transport, chain, paymaster }); +``` + +`fromWalletAdapter` works with any signer that has `{ publicKey: { toBase58() }, signTransaction(VersionedTransaction) }` — including `useWallet()` from `@solana/wallet-adapter-react` and injected providers like Phantom. + +--- + +### Dynamic / other providers + +Dynamic's Solana SDK (`@dynamic-labs-sdk/solana`) exposes `signTransaction({ transaction, walletAccount })` — similar to raw wallet-standard (requires `walletAccount`, returns `{ signedTransaction }`). Would need a thin wrapper similar to the wallet-standard case. Dynamic does **not** match `SolanaSigner` directly. Other providers (Capsule, Turnkey, etc.) have not been verified yet. + +--- + +## Troubleshooting + +| Symptom | Fix | +| --------------------------------- | --------------------------------------------------------------------- | +| `Missing ALCHEMY_API_KEY` | Set the env var before running | +| `RPC error: unauthorized` | API key doesn't have Wallet APIs enabled | +| `RPC error: policy not found` | Policy ID is wrong or not a Solana devnet policy | +| Privy login fails | Check `NEXT_PUBLIC_PRIVY_APP_ID` matches your Privy dashboard app | +| `No Solana embedded wallet found` | Click "Create Solana Wallet" or enable auto-create in Privy dashboard | +| Transaction stays pending | Devnet can be slow — the script polls for up to 60s | diff --git a/docs/docs.yml b/docs/docs.yml index fe9178d856..955a82366b 100644 --- a/docs/docs.yml +++ b/docs/docs.yml @@ -436,14 +436,20 @@ navigation: path: wallets/pages/reference/wallet-apis/src/exports/functions/undelegateAccount.mdx - page: requestQuoteV0 (experimental) path: wallets/pages/reference/wallet-apis/src/exports/experimental/functions/requestQuoteV0.mdx + - section: Interfaces + contents: + - page: SolanaSigner + path: wallets/pages/reference/wallet-apis/src/exports/interfaces/SolanaSigner.mdx - section: Type Aliases contents: - page: AlchemyWalletTransport path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/AlchemyWalletTransport.mdx - - page: BaseWalletClient - path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/BaseWalletClient.mdx + - page: CreateEvmSmartWalletClientParams + path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/CreateEvmSmartWalletClientParams.mdx - page: CreateSmartWalletClientParams path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/CreateSmartWalletClientParams.mdx + - page: CreateSolanaSmartWalletClientParams + path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/CreateSolanaSmartWalletClientParams.mdx - page: FormatSignParams path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/FormatSignParams.mdx - page: FormatSignResult @@ -496,12 +502,12 @@ navigation: path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/SignTypedDataParams.mdx - page: SignTypedDataResult path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/SignTypedDataResult.mdx - - page: SignerClient - path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/SignerClient.mdx - page: SmartWalletActions path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/SmartWalletActions.mdx - page: SmartWalletClient path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/SmartWalletClient.mdx + - page: SolanaSmartWalletClient + path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/SolanaSmartWalletClient.mdx - page: UndelegateAccountParams path: wallets/pages/reference/wallet-apis/src/exports/type-aliases/UndelegateAccountParams.mdx - page: UndelegateAccountResult diff --git a/docs/pages/reference/wallet-apis/src/exports/README.mdx b/docs/pages/reference/wallet-apis/src/exports/README.mdx index 545557143a..83491e4d54 100644 --- a/docs/pages/reference/wallet-apis/src/exports/README.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/README.mdx @@ -38,51 +38,58 @@ npm install @alchemy/wallet-apis viem MIT +## Interfaces + +| Interface | Description | +| :--------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- | +| [SolanaSigner](/wallets/reference/wallet-apis/interfaces/SolanaSigner) | Solana signer interface. Takes serialized tx bytes, returns signed serialized tx bytes. | + ## Type Aliases -| Type Alias | Description | -| :--------------------------------------------------------------------------------------------------------- | :---------- | -| [AlchemyWalletTransport](/wallets/reference/wallet-apis/type-aliases/AlchemyWalletTransport) | - | -| [BaseWalletClient](/wallets/reference/wallet-apis/type-aliases/BaseWalletClient) | - | -| [CreateSmartWalletClientParams](/wallets/reference/wallet-apis/type-aliases/CreateSmartWalletClientParams) | - | -| [FormatSignParams](/wallets/reference/wallet-apis/type-aliases/FormatSignParams) | - | -| [FormatSignResult](/wallets/reference/wallet-apis/type-aliases/FormatSignResult) | - | -| [GetCapabilitiesParams](/wallets/reference/wallet-apis/type-aliases/GetCapabilitiesParams) | - | -| [GetCapabilitiesResult](/wallets/reference/wallet-apis/type-aliases/GetCapabilitiesResult) | - | -| [GrantPermissionsParams](/wallets/reference/wallet-apis/type-aliases/GrantPermissionsParams) | - | -| [GrantPermissionsResult](/wallets/reference/wallet-apis/type-aliases/GrantPermissionsResult) | - | -| [ListAccountsParams](/wallets/reference/wallet-apis/type-aliases/ListAccountsParams) | - | -| [ListAccountsResult](/wallets/reference/wallet-apis/type-aliases/ListAccountsResult) | - | -| [PrepareCallsParams](/wallets/reference/wallet-apis/type-aliases/PrepareCallsParams) | - | -| [PrepareCallsResult](/wallets/reference/wallet-apis/type-aliases/PrepareCallsResult) | - | -| [PrepareSignParams](/wallets/reference/wallet-apis/type-aliases/PrepareSignParams) | - | -| [PrepareSignResult](/wallets/reference/wallet-apis/type-aliases/PrepareSignResult) | - | -| [RequestAccountParams](/wallets/reference/wallet-apis/type-aliases/RequestAccountParams) | - | -| [RequestAccountResult](/wallets/reference/wallet-apis/type-aliases/RequestAccountResult) | - | -| [SendCallsParams](/wallets/reference/wallet-apis/type-aliases/SendCallsParams) | - | -| [SendCallsResult](/wallets/reference/wallet-apis/type-aliases/SendCallsResult) | - | -| [SendPreparedCallsParams](/wallets/reference/wallet-apis/type-aliases/SendPreparedCallsParams) | - | -| [SendPreparedCallsResult](/wallets/reference/wallet-apis/type-aliases/SendPreparedCallsResult) | - | -| [SignerClient](/wallets/reference/wallet-apis/type-aliases/SignerClient) | - | -| [SignMessageParams](/wallets/reference/wallet-apis/type-aliases/SignMessageParams) | - | -| [SignMessageResult](/wallets/reference/wallet-apis/type-aliases/SignMessageResult) | - | -| [SignPreparedCallsParams](/wallets/reference/wallet-apis/type-aliases/SignPreparedCallsParams) | - | -| [SignPreparedCallsResult](/wallets/reference/wallet-apis/type-aliases/SignPreparedCallsResult) | - | -| [SignSignatureRequestParams](/wallets/reference/wallet-apis/type-aliases/SignSignatureRequestParams) | - | -| [SignSignatureRequestResult](/wallets/reference/wallet-apis/type-aliases/SignSignatureRequestResult) | - | -| [SignTypedDataParams](/wallets/reference/wallet-apis/type-aliases/SignTypedDataParams) | - | -| [SignTypedDataResult](/wallets/reference/wallet-apis/type-aliases/SignTypedDataResult) | - | -| [SmartWalletActions](/wallets/reference/wallet-apis/type-aliases/SmartWalletActions) | - | -| [SmartWalletClient](/wallets/reference/wallet-apis/type-aliases/SmartWalletClient) | - | -| [UndelegateAccountParams](/wallets/reference/wallet-apis/type-aliases/UndelegateAccountParams) | - | -| [UndelegateAccountResult](/wallets/reference/wallet-apis/type-aliases/UndelegateAccountResult) | - | +| Type Alias | Description | +| :--------------------------------------------------------------------------------------------------------------------- | :---------- | +| [AlchemyWalletTransport](/wallets/reference/wallet-apis/type-aliases/AlchemyWalletTransport) | - | +| [CreateEvmSmartWalletClientParams](/wallets/reference/wallet-apis/type-aliases/CreateEvmSmartWalletClientParams) | - | +| [CreateSmartWalletClientParams](/wallets/reference/wallet-apis/type-aliases/CreateSmartWalletClientParams) | - | +| [CreateSolanaSmartWalletClientParams](/wallets/reference/wallet-apis/type-aliases/CreateSolanaSmartWalletClientParams) | - | +| [FormatSignParams](/wallets/reference/wallet-apis/type-aliases/FormatSignParams) | - | +| [FormatSignResult](/wallets/reference/wallet-apis/type-aliases/FormatSignResult) | - | +| [GetCapabilitiesParams](/wallets/reference/wallet-apis/type-aliases/GetCapabilitiesParams) | - | +| [GetCapabilitiesResult](/wallets/reference/wallet-apis/type-aliases/GetCapabilitiesResult) | - | +| [GrantPermissionsParams](/wallets/reference/wallet-apis/type-aliases/GrantPermissionsParams) | - | +| [GrantPermissionsResult](/wallets/reference/wallet-apis/type-aliases/GrantPermissionsResult) | - | +| [ListAccountsParams](/wallets/reference/wallet-apis/type-aliases/ListAccountsParams) | - | +| [ListAccountsResult](/wallets/reference/wallet-apis/type-aliases/ListAccountsResult) | - | +| [PrepareCallsParams](/wallets/reference/wallet-apis/type-aliases/PrepareCallsParams) | - | +| [PrepareCallsResult](/wallets/reference/wallet-apis/type-aliases/PrepareCallsResult) | - | +| [PrepareSignParams](/wallets/reference/wallet-apis/type-aliases/PrepareSignParams) | - | +| [PrepareSignResult](/wallets/reference/wallet-apis/type-aliases/PrepareSignResult) | - | +| [RequestAccountParams](/wallets/reference/wallet-apis/type-aliases/RequestAccountParams) | - | +| [RequestAccountResult](/wallets/reference/wallet-apis/type-aliases/RequestAccountResult) | - | +| [SendCallsParams](/wallets/reference/wallet-apis/type-aliases/SendCallsParams) | - | +| [SendCallsResult](/wallets/reference/wallet-apis/type-aliases/SendCallsResult) | - | +| [SendPreparedCallsParams](/wallets/reference/wallet-apis/type-aliases/SendPreparedCallsParams) | - | +| [SendPreparedCallsResult](/wallets/reference/wallet-apis/type-aliases/SendPreparedCallsResult) | - | +| [SignMessageParams](/wallets/reference/wallet-apis/type-aliases/SignMessageParams) | - | +| [SignMessageResult](/wallets/reference/wallet-apis/type-aliases/SignMessageResult) | - | +| [SignPreparedCallsParams](/wallets/reference/wallet-apis/type-aliases/SignPreparedCallsParams) | - | +| [SignPreparedCallsResult](/wallets/reference/wallet-apis/type-aliases/SignPreparedCallsResult) | - | +| [SignSignatureRequestParams](/wallets/reference/wallet-apis/type-aliases/SignSignatureRequestParams) | - | +| [SignSignatureRequestResult](/wallets/reference/wallet-apis/type-aliases/SignSignatureRequestResult) | - | +| [SignTypedDataParams](/wallets/reference/wallet-apis/type-aliases/SignTypedDataParams) | - | +| [SignTypedDataResult](/wallets/reference/wallet-apis/type-aliases/SignTypedDataResult) | - | +| [SmartWalletActions](/wallets/reference/wallet-apis/type-aliases/SmartWalletActions) | - | +| [SmartWalletClient](/wallets/reference/wallet-apis/type-aliases/SmartWalletClient) | - | +| [SolanaSmartWalletClient](/wallets/reference/wallet-apis/type-aliases/SolanaSmartWalletClient) | - | +| [UndelegateAccountParams](/wallets/reference/wallet-apis/type-aliases/UndelegateAccountParams) | - | +| [UndelegateAccountResult](/wallets/reference/wallet-apis/type-aliases/UndelegateAccountResult) | - | ## Functions | Function | Description | | :------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [alchemyWalletTransport](/wallets/reference/wallet-apis/functions/alchemyWalletTransport) | - | -| [createSmartWalletClient](/wallets/reference/wallet-apis/functions/createSmartWalletClient) | Creates a smart wallet client with wallet API actions. | +| [createSmartWalletClient](/wallets/reference/wallet-apis/functions/createSmartWalletClient) | Creates a smart wallet client for EVM or Solana chains. | | [formatSign](/wallets/reference/wallet-apis/functions/formatSign) | Formats a signature request for signing messages or transactions. | | [getCapabilities](/wallets/reference/wallet-apis/functions/getCapabilities) | Gets the capabilities supported by the wallet for the given account. Delegates to viem's `getCapabilities` and renames `paymasterService` to `paymaster` for consistency with the SDK's public API. | | [grantPermissions](/wallets/reference/wallet-apis/functions/grantPermissions) | Grants permissions to a smart account by creating a session. This allows another key to perform operations on behalf of the account. | diff --git a/docs/pages/reference/wallet-apis/src/exports/experimental/variables/swapActions.mdx b/docs/pages/reference/wallet-apis/src/exports/experimental/variables/swapActions.mdx index 80248314da..9934ad6f88 100644 --- a/docs/pages/reference/wallet-apis/src/exports/experimental/variables/swapActions.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/experimental/variables/swapActions.mdx @@ -37,7 +37,7 @@ This is a decorator that is used to add experimental swap actions to a client. - [`BaseWalletClient`](../../type-aliases/BaseWalletClient) + `BaseWalletClient` diff --git a/docs/pages/reference/wallet-apis/src/exports/functions/createSmartWalletClient.mdx b/docs/pages/reference/wallet-apis/src/exports/functions/createSmartWalletClient.mdx index a8016cc50b..7f32b6553a 100644 --- a/docs/pages/reference/wallet-apis/src/exports/functions/createSmartWalletClient.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/functions/createSmartWalletClient.mdx @@ -7,19 +7,76 @@ layout: reference {/* This file is auto-generated by TypeDoc. Do not edit manually. */} +## Call Signature + ```ts function createSmartWalletClient(params): any; ``` -Defined in: [packages/wallet-apis/src/client.ts:34](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/client.ts#L34) +Defined in: [packages/wallet-apis/src/client.ts:115](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/client.ts#L115) + +Creates a smart wallet client for EVM or Solana chains. + +Pass an EVM `Chain` to get a [SmartWalletClient](../type-aliases/SmartWalletClient) with EVM actions. +Pass a Solana chain ID string (e.g. `"solana:devnet"`) with a +[SolanaSigner](../interfaces/SolanaSigner) to get a [SolanaSmartWalletClient](../type-aliases/SolanaSmartWalletClient). + +Imported from `@alchemy/wallet-apis` — works for both chains. +Solana-specific actions and adapters are in `@alchemy/wallet-apis/solana`. + +### Parameters + + + + + + + + + + + + + + + + + + + + +
ParameterTypeDescription
+ `params` + + [`CreateEvmSmartWalletClientParams`](../type-aliases/CreateEvmSmartWalletClientParams) + + EVM or Solana client configuration +
+ +### Returns + +`any` + +A smart wallet client for the specified chain + +## Call Signature + +```ts +function createSmartWalletClient(params): any; +``` + +Defined in: [packages/wallet-apis/src/client.ts:118](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/client.ts#L118) + +Creates a smart wallet client for EVM or Solana chains. -Creates a smart wallet client with wallet API actions. +Pass an EVM `Chain` to get a [SmartWalletClient](../type-aliases/SmartWalletClient) with EVM actions. +Pass a Solana chain ID string (e.g. `"solana:devnet"`) with a +[SolanaSigner](../interfaces/SolanaSigner) to get a [SolanaSmartWalletClient](../type-aliases/SolanaSmartWalletClient). -By default, the client uses EIP-7702 with the signer's address, allowing you to call -`prepareCalls` or `sendCalls` directly without first calling `requestAccount`. -Use `requestAccount` only if you need a non-7702 smart account. +Imported from `@alchemy/wallet-apis` — works for both chains. +Solana-specific actions and adapters are in `@alchemy/wallet-apis/solana`. -## Parameters +### Parameters @@ -37,19 +94,19 @@ Use `requestAccount` only if you need a non-7702 smart account.
- [`CreateSmartWalletClientParams`](../type-aliases/CreateSmartWalletClientParams) + [`CreateSolanaSmartWalletClientParams`](../type-aliases/CreateSolanaSmartWalletClientParams) - Parameters for creating the smart wallet client. + EVM or Solana client configuration
-## Returns +### Returns `any` -A wallet client extended with smart wallet actions. +A smart wallet client for the specified chain diff --git a/docs/pages/reference/wallet-apis/src/exports/functions/prepareCalls.mdx b/docs/pages/reference/wallet-apis/src/exports/functions/prepareCalls.mdx index 42f2b9dc90..dd04ecfd3d 100644 --- a/docs/pages/reference/wallet-apis/src/exports/functions/prepareCalls.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/functions/prepareCalls.mdx @@ -11,7 +11,7 @@ layout: reference function prepareCalls(client, params): Promise; ``` -Defined in: [packages/wallet-apis/src/actions/prepareCalls.ts:82](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/prepareCalls.ts#L82) +Defined in: [packages/wallet-apis/src/actions/prepareCalls.ts:94](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/prepareCalls.ts#L94) Prepares a set of contract calls for execution by building a user operation. Returns the built user operation and a signature request that needs to be signed diff --git a/docs/pages/reference/wallet-apis/src/exports/functions/sendPreparedCalls.mdx b/docs/pages/reference/wallet-apis/src/exports/functions/sendPreparedCalls.mdx index 1579a6c079..d34627cdc9 100644 --- a/docs/pages/reference/wallet-apis/src/exports/functions/sendPreparedCalls.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/functions/sendPreparedCalls.mdx @@ -8,10 +8,10 @@ layout: reference {/* This file is auto-generated by TypeDoc. Do not edit manually. */} ```ts -function sendPreparedCalls(client, params): Promise; +function sendPreparedCalls(client, params): Promise<{} | {}>; ``` -Defined in: [packages/wallet-apis/src/actions/sendPreparedCalls.ts:63](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/sendPreparedCalls.ts#L63) +Defined in: [packages/wallet-apis/src/actions/sendPreparedCalls.ts:67](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/sendPreparedCalls.ts#L67) Sends prepared calls by submitting a signed user operation. This method is used after signing the signature request returned from prepareCalls. @@ -87,6 +87,10 @@ const result = await client.sendPreparedCalls({ ## Returns -`Promise`\<[`SendPreparedCallsResult`](../type-aliases/SendPreparedCallsResult)> +`Promise`\< +| \{ +} +| \{ +}> A Promise that resolves to the result containing the call ID diff --git a/docs/pages/reference/wallet-apis/src/exports/interfaces/SolanaSigner.mdx b/docs/pages/reference/wallet-apis/src/exports/interfaces/SolanaSigner.mdx new file mode 100644 index 0000000000..dbff1e4c70 --- /dev/null +++ b/docs/pages/reference/wallet-apis/src/exports/interfaces/SolanaSigner.mdx @@ -0,0 +1,88 @@ +--- +title: SolanaSigner +description: Solana signer interface. Takes serialized tx bytes, returns signed serialized tx bytes. +slug: wallets/reference/wallet-apis/interfaces/SolanaSigner +layout: reference +--- + +{/* This file is auto-generated by TypeDoc. Do not edit manually. */} + +Defined in: [packages/wallet-apis/src/types.ts:43](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/types.ts#L43) + +Solana signer interface. Takes serialized tx bytes, returns signed serialized tx bytes. + +## Properties + + + + + + + + + + + + + + + + + +
PropertyType
+ `address` + + `string` +
+ +## Methods + +### signTransaction() + +```ts +signTransaction(input): Promise<{ + signedTransaction: Uint8Array; +}>; +``` + +Defined in: [packages/wallet-apis/src/types.ts:45](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/types.ts#L45) + +#### Parameters + + + + + + + + + + + + + + + + + + + + + + + +
ParameterType
+ `input` + + \{ \[`key`: `string`]: `unknown`; `transaction`: `Uint8Array`; } +
+ `input.transaction` + + `Uint8Array` +
+ +#### Returns + +`Promise`\<\{ +`signedTransaction`: `Uint8Array`; +}> diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/BaseWalletClient.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/BaseWalletClient.mdx deleted file mode 100644 index 0444f1fd02..0000000000 --- a/docs/pages/reference/wallet-apis/src/exports/type-aliases/BaseWalletClient.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: BaseWalletClient -description: Overview of BaseWalletClient -slug: wallets/reference/wallet-apis/type-aliases/BaseWalletClient -layout: reference ---- - -{/* This file is auto-generated by TypeDoc. Do not edit manually. */} - -```ts -type BaseWalletClient = Client< - Transport<"alchemyHttp">, - Chain, - JsonRpcAccount
, - WalletServerViemRpcSchema, - TExtend ->; -``` - -Defined in: [packages/wallet-apis/src/types.ts:16](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/types.ts#L16) - -## Type Parameters - - - - - - - - - - - - - - - - - -
Type ParameterDefault type
- `TExtend` *extends* - | \{ - \[`key`: `string`]: `unknown`; - } - | `undefined` - - | \{ - \[`key`: `string`]: `unknown`; - } - | `undefined` -
diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateEvmSmartWalletClientParams.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateEvmSmartWalletClientParams.mdx new file mode 100644 index 0000000000..6b0958d770 --- /dev/null +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateEvmSmartWalletClientParams.mdx @@ -0,0 +1,107 @@ +--- +title: CreateEvmSmartWalletClientParams +description: Overview of CreateEvmSmartWalletClientParams +slug: wallets/reference/wallet-apis/type-aliases/CreateEvmSmartWalletClientParams +layout: reference +--- + +{/* This file is auto-generated by TypeDoc. Do not edit manually. */} + +```ts +type CreateEvmSmartWalletClientParams = { + signer: SmartWalletSigner; + transport: AlchemyWalletTransport; + chain: Chain; + account?: Address; + paymaster?: { + policyId?: string; + policyIds?: string[]; + }; +}; +``` + +Defined in: [packages/wallet-apis/src/client.ts:69](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/client.ts#L69) + +## Properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyType
+ `account?` + + [`Address`](https://abitype.dev) +
+ `chain` + + [`Chain`](https://viem.sh) +
+ `paymaster?` + + `object` +
+ `paymaster.policyId?` + + `string` +
+ `paymaster.policyIds?` + + `string`\[] +
+ `signer` + + `SmartWalletSigner` +
+ `transport` + + [`AlchemyWalletTransport`](AlchemyWalletTransport) +
diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateSmartWalletClientParams.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateSmartWalletClientParams.mdx index 9c8c913f78..97f474cfdf 100644 --- a/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateSmartWalletClientParams.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateSmartWalletClientParams.mdx @@ -8,100 +8,9 @@ layout: reference {/* This file is auto-generated by TypeDoc. Do not edit manually. */} ```ts -type CreateSmartWalletClientParams = { - signer: SmartWalletSigner; - transport: AlchemyWalletTransport; - chain: Chain; - account?: Address; - paymaster?: { - policyId?: string; - policyIds?: string[]; - }; -}; +type CreateSmartWalletClientParams = + | CreateEvmSmartWalletClientParams + | CreateSolanaSmartWalletClientParams; ``` -Defined in: [packages/wallet-apis/src/client.ts:8](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/client.ts#L8) - -## Properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyType
- `account?` - - [`Address`](https://abitype.dev) -
- `chain` - - [`Chain`](https://viem.sh) -
- `paymaster?` - - `object` -
- `paymaster.policyId?` - - `string` -
- `paymaster.policyIds?` - - `string`\[] -
- `signer` - - `SmartWalletSigner` -
- `transport` - - [`AlchemyWalletTransport`](AlchemyWalletTransport) -
+Defined in: [packages/wallet-apis/src/client.ts:90](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/client.ts#L90) diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateSolanaSmartWalletClientParams.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateSolanaSmartWalletClientParams.mdx new file mode 100644 index 0000000000..040aa2fc4a --- /dev/null +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/CreateSolanaSmartWalletClientParams.mdx @@ -0,0 +1,96 @@ +--- +title: CreateSolanaSmartWalletClientParams +description: Overview of CreateSolanaSmartWalletClientParams +slug: wallets/reference/wallet-apis/type-aliases/CreateSolanaSmartWalletClientParams +layout: reference +--- + +{/* This file is auto-generated by TypeDoc. Do not edit manually. */} + +```ts +type CreateSolanaSmartWalletClientParams = { + signer: SolanaSigner; + transport: AlchemyWalletTransport; + chain: SolanaChainId; + account?: string; + paymaster?: { + policyId: string; + }; +}; +``` + +Defined in: [packages/wallet-apis/src/client.ts:80](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/client.ts#L80) + +## Properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyType
+ `account?` + + `string` +
+ `chain` + + `SolanaChainId` +
+ `paymaster?` + + `object` +
+ `paymaster.policyId` + + `string` +
+ `signer` + + [`SolanaSigner`](../interfaces/SolanaSigner) +
+ `transport` + + [`AlchemyWalletTransport`](AlchemyWalletTransport) +
diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/PrepareCallsParams.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/PrepareCallsParams.mdx index 765f6d19c2..d7e0363f7d 100644 --- a/docs/pages/reference/wallet-apis/src/exports/type-aliases/PrepareCallsParams.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/PrepareCallsParams.mdx @@ -13,4 +13,4 @@ type PrepareCallsParams = Prettify< >; ``` -Defined in: [packages/wallet-apis/src/actions/prepareCalls.ts:25](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/prepareCalls.ts#L25) +Defined in: [packages/wallet-apis/src/actions/prepareCalls.ts:37](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/prepareCalls.ts#L37) diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/PrepareCallsResult.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/PrepareCallsResult.mdx index 903b629177..7fc7ce2a1a 100644 --- a/docs/pages/reference/wallet-apis/src/exports/type-aliases/PrepareCallsResult.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/PrepareCallsResult.mdx @@ -26,4 +26,4 @@ type PrepareCallsResult = >; ``` -Defined in: [packages/wallet-apis/src/actions/prepareCalls.ts:42](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/prepareCalls.ts#L42) +Defined in: [packages/wallet-apis/src/actions/prepareCalls.ts:54](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/prepareCalls.ts#L54) diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SendPreparedCallsParams.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SendPreparedCallsParams.mdx index 2e82184d0a..62dabef6b8 100644 --- a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SendPreparedCallsParams.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SendPreparedCallsParams.mdx @@ -13,4 +13,4 @@ type SendPreparedCallsParams = Prettify< >; ``` -Defined in: [packages/wallet-apis/src/actions/sendPreparedCalls.ts:22](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/sendPreparedCalls.ts#L22) +Defined in: [packages/wallet-apis/src/actions/sendPreparedCalls.ts:26](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/sendPreparedCalls.ts#L26) diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SendPreparedCallsResult.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SendPreparedCallsResult.mdx index 934f6dbae4..643cec430e 100644 --- a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SendPreparedCallsResult.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SendPreparedCallsResult.mdx @@ -11,4 +11,4 @@ layout: reference type SendPreparedCallsResult = SendPreparedCallsResponse; ``` -Defined in: [packages/wallet-apis/src/actions/sendPreparedCalls.ts:30](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/sendPreparedCalls.ts#L30) +Defined in: [packages/wallet-apis/src/actions/sendPreparedCalls.ts:34](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/sendPreparedCalls.ts#L34) diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SignerClient.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SignerClient.mdx deleted file mode 100644 index 8d701cc66c..0000000000 --- a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SignerClient.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: SignerClient -description: Overview of SignerClient -slug: wallets/reference/wallet-apis/type-aliases/SignerClient -layout: reference ---- - -{/* This file is auto-generated by TypeDoc. Do not edit manually. */} - -```ts -type SignerClient = WalletClient; -``` - -Defined in: [packages/wallet-apis/src/types.ts:34](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/types.ts#L34) diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SmartWalletClient.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SmartWalletClient.mdx index d55ec54d43..1cec21ab74 100644 --- a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SmartWalletClient.mdx +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SmartWalletClient.mdx @@ -11,4 +11,4 @@ layout: reference type SmartWalletClient = BaseWalletClient; ``` -Defined in: [packages/wallet-apis/src/types.ts:38](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/types.ts#L38) +Defined in: [packages/wallet-apis/src/types.ts:35](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/types.ts#L35) diff --git a/docs/pages/reference/wallet-apis/src/exports/type-aliases/SolanaSmartWalletClient.mdx b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SolanaSmartWalletClient.mdx new file mode 100644 index 0000000000..4020ee3355 --- /dev/null +++ b/docs/pages/reference/wallet-apis/src/exports/type-aliases/SolanaSmartWalletClient.mdx @@ -0,0 +1,17 @@ +--- +title: SolanaSmartWalletClient +description: Overview of SolanaSmartWalletClient +slug: wallets/reference/wallet-apis/type-aliases/SolanaSmartWalletClient +layout: reference +--- + +{/* This file is auto-generated by TypeDoc. Do not edit manually. */} + +```ts +type SolanaSmartWalletClient = BaseWalletClient< + SolanaSmartWalletActions, + undefined +>; +``` + +Defined in: [packages/wallet-apis/src/types.ts:37](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/types.ts#L37) diff --git a/examples/solana-privy/.env.example b/examples/solana-privy/.env.example new file mode 100644 index 0000000000..e1fd2b533a --- /dev/null +++ b/examples/solana-privy/.env.example @@ -0,0 +1,3 @@ +NEXT_PUBLIC_PRIVY_APP_ID= +NEXT_PUBLIC_ALCHEMY_API_KEY= +NEXT_PUBLIC_SOLANA_POLICY_ID= diff --git a/examples/solana-privy/next-env.d.ts b/examples/solana-privy/next-env.d.ts new file mode 100644 index 0000000000..830fb594ca --- /dev/null +++ b/examples/solana-privy/next-env.d.ts @@ -0,0 +1,6 @@ +/// +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/examples/solana-privy/next.config.ts b/examples/solana-privy/next.config.ts new file mode 100644 index 0000000000..2f6491cfba --- /dev/null +++ b/examples/solana-privy/next.config.ts @@ -0,0 +1,7 @@ +import type { NextConfig } from "next"; + +const nextConfig: NextConfig = { + reactStrictMode: true, +}; + +export default nextConfig; diff --git a/examples/solana-privy/package.json b/examples/solana-privy/package.json new file mode 100644 index 0000000000..9ef93eaba4 --- /dev/null +++ b/examples/solana-privy/package.json @@ -0,0 +1,25 @@ +{ + "name": "solana-privy-example", + "private": true, + "scripts": { + "dev": "next dev", + "build": "next build" + }, + "dependencies": { + "@alchemy/wallet-apis": "workspace:*", + "@privy-io/react-auth": "^2.11.0", + "@solana/kit": "^2.3.0", + "@solana/spl-token": "^0.4.14", + "@solana/web3.js": "^1.98.4", + "@wallet-standard/app": "^1.1.0", + "@wallet-standard/base": "^1.1.0", + "next": "^15.3.0", + "ox": "^0.11.1", + "react": "^19.1.0", + "react-dom": "^19.1.0" + }, + "devDependencies": { + "@types/react": "^19.1.0", + "typescript": "^5.9.3" + } +} diff --git a/examples/solana-privy/src/app/layout.tsx b/examples/solana-privy/src/app/layout.tsx new file mode 100644 index 0000000000..11adcf2a4b --- /dev/null +++ b/examples/solana-privy/src/app/layout.tsx @@ -0,0 +1,89 @@ +"use client"; + +import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { PrivyProvider } from "@privy-io/react-auth"; +import { createSolanaRpc, createSolanaRpcSubscriptions } from "@solana/kit"; + +const ALCHEMY_API_KEY = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY!; + +const SOLANA_DEVNET_RPC = `https://solana-devnet.g.alchemypreview.com/v2/${ALCHEMY_API_KEY}`; +const SOLANA_DEVNET_WS = `wss://solana-devnet.g.alchemypreview.com/v2/${ALCHEMY_API_KEY}`; +const SOLANA_MAINNET_RPC = `https://solana-mainnet.g.alchemypreview.com/v2/${ALCHEMY_API_KEY}`; +const SOLANA_MAINNET_WS = `wss://solana-mainnet.g.alchemypreview.com/v2/${ALCHEMY_API_KEY}`; + +const NAV_LINKS = [ + { href: "/", label: "Privy" }, + { href: "/wallet-standard", label: "Wallet Standard" }, + { href: "/phantom-raw", label: "Phantom Raw" }, +]; + +function Nav() { + const pathname = usePathname(); + return ( + + ); +} + +export default function RootLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + +