@account-kit/privy-integration 4.68.0 → 4.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,7 @@ If you're already using [Privy](https://privy.io) for authentication, this packa
9
9
  - **🔄 EIP-7702 Delegation** - Upgrade EOAs to smart accounts without migration
10
10
  - **⛽ Gas Sponsorship** - Pay gas fees for your users via Alchemy Gas Manager
11
11
  - **💱 Token Swaps** - Execute swaps through Alchemy's swap infrastructure
12
- - **🚀 Batched Transactions** - Send multiple operations in a single transaction
12
+ - **🚀 Batched Transactions** - Send multiple operations in a single transaction using `sendTransaction([...])`
13
13
 
14
14
  All while keeping Privy as your authentication provider. No need to change your auth flow or migrate user accounts.
15
15
 
@@ -73,6 +73,7 @@ function SendButton() {
73
73
 
74
74
  const handleSend = async () => {
75
75
  try {
76
+ // Single transaction
76
77
  const result = await sendTransaction({
77
78
  to: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
78
79
  data: "0x...",
@@ -85,10 +86,30 @@ function SendButton() {
85
86
  }
86
87
  };
87
88
 
89
+ const handleBatch = async () => {
90
+ try {
91
+ // Batch transactions
92
+ const result = await sendTransaction([
93
+ { to: "0x...", data: "0x...", value: "1000000000000000000" },
94
+ { to: "0x...", data: "0x..." },
95
+ { to: "0x...", data: "0x..." },
96
+ ]);
97
+
98
+ console.log("Batch transaction hash:", result.txnHash);
99
+ } catch (err) {
100
+ console.error("Batch transaction failed:", err);
101
+ }
102
+ };
103
+
88
104
  return (
89
- <button onClick={handleSend} disabled={isLoading}>
90
- {isLoading ? "Sending..." : "Send Transaction"}
91
- </button>
105
+ <>
106
+ <button onClick={handleSend} disabled={isLoading}>
107
+ {isLoading ? "Sending..." : "Send Transaction"}
108
+ </button>
109
+ <button onClick={handleBatch} disabled={isLoading}>
110
+ {isLoading ? "Sending..." : "Send Batch"}
111
+ </button>
112
+ </>
92
113
  );
93
114
  }
94
115
  ```
@@ -185,11 +206,13 @@ await sendTransaction(
185
206
 
186
207
  #### `useAlchemySendTransaction()`
187
208
 
188
- Send transactions with optional gas sponsorship.
209
+ Send single or batch transactions with optional gas sponsorship.
189
210
 
190
211
  **Returns:**
191
212
 
192
- - `sendTransaction(input, options?)` - Send a transaction
213
+ - `sendTransaction(input, options?)` - Send a single transaction or batch of transactions
214
+ - `input` - Single `UnsignedTransactionRequest` or array of them
215
+ - `options` - Optional `SendTransactionOptions`
193
216
  - `isLoading` - Loading state
194
217
  - `error` - Error object if failed
195
218
  - `data` - Transaction result with `txnHash`
@@ -300,7 +323,7 @@ The API is nearly identical, making migration seamless.
300
323
 
301
324
  ### Access the Smart Wallet Client
302
325
 
303
- For advanced use cases, access the underlying client:
326
+ For advanced use cases, access the underlying client directly:
304
327
 
305
328
  ```tsx
306
329
  import { useAlchemyClient } from "@account-kit/privy-integration";
@@ -314,7 +337,7 @@ function AdvancedComponent() {
314
337
  // Use any SmartWalletClient method
315
338
  const address = await client.getAddress();
316
339
 
317
- // Batch multiple calls
340
+ // Direct access to sendCalls with full control
318
341
  await client.sendCalls({
319
342
  from: address,
320
343
  calls: [
@@ -326,6 +349,8 @@ function AdvancedComponent() {
326
349
  paymasterService: { policyId: "your-policy-id" },
327
350
  },
328
351
  });
352
+
353
+ // Note: For most cases, use useAlchemySendTransaction instead
329
354
  };
330
355
 
331
356
  return <button onClick={doAdvancedOperation}>Advanced Op</button>;
@@ -1,11 +1,12 @@
1
1
  import type { UseSendTransactionResult } from "../types";
2
2
  /**
3
3
  * Hook to send transactions with optional gas sponsorship via Alchemy
4
+ * Supports both single transactions and batch transactions
4
5
  * Drop-in alternative to Privy's useSendTransaction hook
5
6
  *
6
7
  * @returns {UseSendTransactionResult} Hook result with sendTransaction function and state
7
8
  *
8
- * @example
9
+ * @example Single transaction
9
10
  * ```tsx
10
11
  * const { sendTransaction, isLoading, error, data } = useAlchemySendTransaction();
11
12
  *
@@ -22,5 +23,15 @@ import type { UseSendTransactionResult } from "../types";
22
23
  * }
23
24
  * };
24
25
  * ```
26
+ *
27
+ * @example Batch transactions
28
+ * ```tsx
29
+ * const { sendTransaction } = useAlchemySendTransaction();
30
+ *
31
+ * const result = await sendTransaction([
32
+ * { to: '0x...', data: '0x...', value: '1000000000000000000' },
33
+ * { to: '0x...', data: '0x...' },
34
+ * ]);
35
+ * ```
25
36
  */
26
37
  export declare function useAlchemySendTransaction(): UseSendTransactionResult;
@@ -25,11 +25,12 @@ function normalizeValue(value) {
25
25
  }
26
26
  /**
27
27
  * Hook to send transactions with optional gas sponsorship via Alchemy
28
+ * Supports both single transactions and batch transactions
28
29
  * Drop-in alternative to Privy's useSendTransaction hook
29
30
  *
30
31
  * @returns {UseSendTransactionResult} Hook result with sendTransaction function and state
31
32
  *
32
- * @example
33
+ * @example Single transaction
33
34
  * ```tsx
34
35
  * const { sendTransaction, isLoading, error, data } = useAlchemySendTransaction();
35
36
  *
@@ -46,6 +47,16 @@ function normalizeValue(value) {
46
47
  * }
47
48
  * };
48
49
  * ```
50
+ *
51
+ * @example Batch transactions
52
+ * ```tsx
53
+ * const { sendTransaction } = useAlchemySendTransaction();
54
+ *
55
+ * const result = await sendTransaction([
56
+ * { to: '0x...', data: '0x...', value: '1000000000000000000' },
57
+ * { to: '0x...', data: '0x...' },
58
+ * ]);
59
+ * ```
49
60
  */
50
61
  export function useAlchemySendTransaction() {
51
62
  const { getClient } = useAlchemyClient();
@@ -66,12 +77,13 @@ export function useAlchemySendTransaction() {
66
77
  const shouldSponsor = options?.disableSponsorship !== undefined
67
78
  ? !options.disableSponsorship
68
79
  : hasPolicyId && enableSponsorship;
69
- // Format the transaction call
70
- const formattedCall = {
71
- to: input.to,
72
- data: input.data,
73
- value: input.value ? normalizeValue(input.value) : undefined,
74
- };
80
+ // Format the transaction call(s)
81
+ const inputs = Array.isArray(input) ? input : [input];
82
+ const formattedCalls = inputs.map((txn) => ({
83
+ to: txn.to,
84
+ data: txn.data,
85
+ value: txn.value ? normalizeValue(txn.value) : undefined,
86
+ }));
75
87
  // Build capabilities based on sponsorship
76
88
  const policyId = Array.isArray(config.policyId)
77
89
  ? config.policyId[0]
@@ -80,10 +92,10 @@ export function useAlchemySendTransaction() {
80
92
  if (shouldSponsor && policyId) {
81
93
  capabilities.paymasterService = { policyId };
82
94
  }
83
- // Send the transaction
95
+ // Send the transaction(s)
84
96
  const result = await client.sendCalls({
85
97
  from: embeddedWallet.address,
86
- calls: [formattedCall],
98
+ calls: formattedCalls,
87
99
  capabilities,
88
100
  });
89
101
  if (!result.preparedCallIds || result.preparedCallIds.length === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"useAlchemySendTransaction.js","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAA0B,KAAK,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAQpE;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,KAA+B;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,wBAAwB;IACxB,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAA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AC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,GACZ,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;YAC/D,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnB,MAAM,QAAQ,CAAC;QACjB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD,CAAC,SAAS,EAAE,iBAAiB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAC3E,CAAC;IAEF,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,eAAe;QACf,SAAS;QACT,KAAK;QACL,IAAI;QACJ,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from \"react\";\nimport { type Address, type Hex, isHex } from \"viem\";\nimport { useAlchemyClient } from \"./useAlchemyClient.js\";\nimport { useAlchemyConfig } from \"../Provider.js\";\nimport { useEmbeddedWallet } from \"./internal/useEmbeddedWallet.js\";\nimport type {\n UnsignedTransactionRequest,\n SendTransactionOptions,\n SendTransactionResult,\n UseSendTransactionResult,\n} from \"../types\";\n\n/**\n * Normalize value to hex format\n * Accepts bigint, number, decimal string, or hex string\n *\n * @param {string | number | bigint} value - Value to normalize\n * @returns {Hex} Hex string representation of the value\n */\nfunction normalizeValue(value: string | number | bigint): Hex {\n if (typeof value === \"bigint\") {\n return `0x${value.toString(16)}`;\n }\n if (typeof value === \"number\") {\n return `0x${BigInt(value).toString(16)}`;\n }\n if (isHex(value)) {\n return value;\n }\n // Assume decimal string\n return `0x${BigInt(value).toString(16)}`;\n}\n\n/**\n * Hook to send transactions with optional gas sponsorship via Alchemy\n * Drop-in alternative to Privy's useSendTransaction hook\n *\n * @returns {UseSendTransactionResult} Hook result with sendTransaction function and state\n *\n * @example\n * ```tsx\n * const { sendTransaction, isLoading, error, data } = useAlchemySendTransaction();\n *\n * const handleSend = async () => {\n * try {\n * const result = await sendTransaction({\n * to: '0x...',\n * data: '0x...',\n * value: '1000000000000000000', // 1 ETH\n * });\n * console.log('Transaction hash:', result.txnHash);\n * } catch (err) {\n * console.error('Transaction failed:', err);\n * }\n * };\n * ```\n */\nexport function useAlchemySendTransaction(): UseSendTransactionResult {\n const { getClient } = useAlchemyClient();\n const config = useAlchemyConfig();\n const getEmbeddedWallet = useEmbeddedWallet();\n\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<SendTransactionResult | null>(null);\n\n const sendTransaction = useCallback(\n async (\n input: UnsignedTransactionRequest,\n options?: SendTransactionOptions,\n ): Promise<SendTransactionResult> => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = await getClient();\n const embeddedWallet = getEmbeddedWallet();\n\n // Determine if transaction should be sponsored\n const hasPolicyId = !!config.policyId;\n const enableSponsorship = !config.disableSponsorship;\n const shouldSponsor =\n options?.disableSponsorship !== undefined\n ? !options.disableSponsorship\n : hasPolicyId && enableSponsorship;\n\n // Format the transaction call\n const formattedCall = {\n to: input.to,\n data: input.data,\n value: input.value ? normalizeValue(input.value) : undefined,\n };\n\n // Build capabilities based on sponsorship\n const policyId = Array.isArray(config.policyId)\n ? config.policyId[0]\n : config.policyId;\n\n const capabilities: {\n eip7702Auth: true;\n paymasterService?: { policyId: string };\n } = { eip7702Auth: true };\n\n if (shouldSponsor && policyId) {\n capabilities.paymasterService = { policyId };\n }\n\n // Send the transaction\n const result = await client.sendCalls({\n from: embeddedWallet.address as Address,\n calls: [formattedCall],\n capabilities,\n });\n\n if (!result.preparedCallIds || result.preparedCallIds.length === 0) {\n throw new Error(\n \"No prepared call IDs returned from transaction submission\",\n );\n }\n\n // Wait for the transaction to be confirmed\n const txStatus = await client.waitForCallsStatus({\n id: result.preparedCallIds[0],\n timeout: 60_000,\n });\n\n const txnHash = txStatus.receipts?.[0]?.transactionHash;\n if (!txnHash) {\n throw new Error(\"Transaction hash not found in receipt\");\n }\n\n const txResult: SendTransactionResult = { txnHash };\n setData(txResult);\n return txResult;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error(\"Transaction failed\");\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n },\n [getClient, getEmbeddedWallet, config.policyId, config.disableSponsorship],\n );\n\n const reset = useCallback(() => {\n setError(null);\n setData(null);\n setIsLoading(false);\n }, []);\n\n return {\n sendTransaction,\n isLoading,\n error,\n data,\n reset,\n };\n}\n"]}
1
+ {"version":3,"file":"useAlchemySendTransaction.js","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAA0B,KAAK,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAQpE;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,KAA+B;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,EAA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,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC;YACxD,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;YAC3D,CAAC;YAED,MAAM,QAAQ,GAA0B,EAAE,OAAO,EAAE,CAAC;YACpD,OAAO,CAAC,QAAQ,CAAC,CAAC;YAClB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,GACZ,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;YAC/D,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnB,MAAM,QAAQ,CAAC;QACjB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD,CAAC,SAAS,EAAE,iBAAiB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAC3E,CAAC;IAEF,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,eAAe;QACf,SAAS;QACT,KAAK;QACL,IAAI;QACJ,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from \"react\";\nimport { type Address, type Hex, isHex } from \"viem\";\nimport { useAlchemyClient } from \"./useAlchemyClient.js\";\nimport { useAlchemyConfig } from \"../Provider.js\";\nimport { useEmbeddedWallet } from \"./internal/useEmbeddedWallet.js\";\nimport type {\n UnsignedTransactionRequest,\n SendTransactionOptions,\n SendTransactionResult,\n UseSendTransactionResult,\n} from \"../types\";\n\n/**\n * Normalize value to hex format\n * Accepts bigint, number, decimal string, or hex string\n *\n * @param {string | number | bigint} value - Value to normalize\n * @returns {Hex} Hex string representation of the value\n */\nfunction normalizeValue(value: string | number | bigint): Hex {\n if (typeof value === \"bigint\") {\n return `0x${value.toString(16)}`;\n }\n if (typeof value === \"number\") {\n return `0x${BigInt(value).toString(16)}`;\n }\n if (isHex(value)) {\n return value;\n }\n // Assume decimal string\n return `0x${BigInt(value).toString(16)}`;\n}\n\n/**\n * Hook to send transactions with optional gas sponsorship via Alchemy\n * Supports both single transactions and batch transactions\n * Drop-in alternative to Privy's useSendTransaction hook\n *\n * @returns {UseSendTransactionResult} Hook result with sendTransaction function and state\n *\n * @example Single transaction\n * ```tsx\n * const { sendTransaction, isLoading, error, data } = useAlchemySendTransaction();\n *\n * const handleSend = async () => {\n * try {\n * const result = await sendTransaction({\n * to: '0x...',\n * data: '0x...',\n * value: '1000000000000000000', // 1 ETH\n * });\n * console.log('Transaction hash:', result.txnHash);\n * } catch (err) {\n * console.error('Transaction failed:', err);\n * }\n * };\n * ```\n *\n * @example Batch transactions\n * ```tsx\n * const { sendTransaction } = useAlchemySendTransaction();\n *\n * const result = await sendTransaction([\n * { to: '0x...', data: '0x...', value: '1000000000000000000' },\n * { to: '0x...', data: '0x...' },\n * ]);\n * ```\n */\nexport function useAlchemySendTransaction(): UseSendTransactionResult {\n const { getClient } = useAlchemyClient();\n const config = useAlchemyConfig();\n const getEmbeddedWallet = useEmbeddedWallet();\n\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<SendTransactionResult | null>(null);\n\n const sendTransaction = useCallback(\n async (\n input: UnsignedTransactionRequest | UnsignedTransactionRequest[],\n options?: SendTransactionOptions,\n ): Promise<SendTransactionResult> => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = await getClient();\n const embeddedWallet = getEmbeddedWallet();\n\n // Determine if transaction should be sponsored\n const hasPolicyId = !!config.policyId;\n const enableSponsorship = !config.disableSponsorship;\n const shouldSponsor =\n options?.disableSponsorship !== undefined\n ? !options.disableSponsorship\n : hasPolicyId && enableSponsorship;\n\n // Format the transaction call(s)\n const inputs = Array.isArray(input) ? input : [input];\n const formattedCalls = inputs.map((txn) => ({\n to: txn.to,\n data: txn.data,\n value: txn.value ? normalizeValue(txn.value) : undefined,\n }));\n\n // Build capabilities based on sponsorship\n const policyId = Array.isArray(config.policyId)\n ? config.policyId[0]\n : config.policyId;\n\n const capabilities: {\n eip7702Auth: true;\n paymasterService?: { policyId: string };\n } = { eip7702Auth: true };\n\n if (shouldSponsor && policyId) {\n capabilities.paymasterService = { policyId };\n }\n\n // Send the transaction(s)\n const result = await client.sendCalls({\n from: embeddedWallet.address as Address,\n calls: formattedCalls,\n capabilities,\n });\n\n if (!result.preparedCallIds || result.preparedCallIds.length === 0) {\n throw new Error(\n \"No prepared call IDs returned from transaction submission\",\n );\n }\n\n // Wait for the transaction to be confirmed\n const txStatus = await client.waitForCallsStatus({\n id: result.preparedCallIds[0],\n timeout: 60_000,\n });\n\n const txnHash = txStatus.receipts?.[0]?.transactionHash;\n if (!txnHash) {\n throw new Error(\"Transaction hash not found in receipt\");\n }\n\n const txResult: SendTransactionResult = { txnHash };\n setData(txResult);\n return txResult;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error(\"Transaction failed\");\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n },\n [getClient, getEmbeddedWallet, config.policyId, config.disableSponsorship],\n );\n\n const reset = useCallback(() => {\n setError(null);\n setData(null);\n setIsLoading(false);\n }, []);\n\n return {\n sendTransaction,\n isLoading,\n error,\n data,\n reset,\n };\n}\n"]}
@@ -55,8 +55,8 @@ export interface UseSendTransactionResult {
55
55
  data: SendTransactionResult | null;
56
56
  /** Reset the hook state */
57
57
  reset(): void;
58
- /** Send a transaction */
59
- sendTransaction(input: UnsignedTransactionRequest, options?: SendTransactionOptions): Promise<SendTransactionResult>;
58
+ /** Send a single transaction or batch of transactions */
59
+ sendTransaction(input: UnsignedTransactionRequest | UnsignedTransactionRequest[], options?: SendTransactionOptions): Promise<SendTransactionResult>;
60
60
  }
61
61
  /**
62
62
  * Request parameters for preparing a swap
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import type { Address, Hash, Hex } from \"viem\";\nimport type { swapActions } from \"@account-kit/wallet-client/experimental\";\nimport { ConnectionConfigSchema } from \"@aa-sdk/core\";\nimport type { z } from \"zod\";\n\n/**\n * Configuration for the Alchemy provider\n * Uses ConnectionConfigSchema to ensure valid transport configuration\n */\nexport type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {\n /** Policy ID(s) for gas sponsorship */\n policyId?: string | string[];\n\n /**\n * Set to true to disable gas sponsorship by default\n * Default: false (sponsorship enabled when policyId is provided)\n */\n disableSponsorship?: boolean;\n};\n\n/**\n * Unsigned transaction request\n */\nexport interface UnsignedTransactionRequest {\n /** Recipient address */\n to: Address;\n\n /** Transaction data (calldata) */\n data?: Hex;\n\n /** Transaction value - accepts string | number | bigint */\n value?: string | number | bigint;\n}\n\n/**\n * Options for sending a transaction\n */\nexport interface SendTransactionOptions {\n /**\n * Set to true to disable sponsorship for this specific transaction\n * Default: false (follows provider's disableSponsorship setting)\n */\n disableSponsorship?: boolean;\n}\n\n/**\n * Result of a successful transaction\n */\nexport interface SendTransactionResult {\n /** EVM transaction hash (first receipt hash) */\n txnHash: Hash;\n}\n\n/**\n * Hook result for sending transactions\n */\nexport interface UseSendTransactionResult {\n /** Whether the transaction is currently being sent */\n isLoading: boolean;\n\n /** Error if transaction failed */\n error: Error | null;\n\n /** Transaction result if successful */\n data: SendTransactionResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Send a transaction */\n sendTransaction(\n input: UnsignedTransactionRequest,\n options?: SendTransactionOptions,\n ): Promise<SendTransactionResult>;\n}\n\n/**\n * Request parameters for preparing a swap\n * Derived directly from the SDK to ensure type safety\n *\n * Note: Provide either `fromAmount` OR `minimumToAmount`, not both.\n * - Use `fromAmount` to specify exact amount to swap FROM\n * - Use `minimumToAmount` to specify minimum amount to receive TO\n */\nexport type PrepareSwapRequest = Parameters<\n ReturnType<typeof swapActions>[\"requestQuoteV0\"]\n>[0];\n\n/**\n * Response from requestQuoteV0\n * Derived directly from the SDK to ensure type safety\n */\nexport type RequestQuoteV0Result = Awaited<\n ReturnType<ReturnType<typeof swapActions>[\"requestQuoteV0\"]>\n>;\n\n/**\n * Swap quote information extracted from prepared swap calls\n * Derived directly from the SDK response\n */\nexport type SwapQuote = NonNullable<RequestQuoteV0Result[\"quote\"]>;\n\n/**\n * Result of preparing a swap (full response from requestQuoteV0)\n * Contains quote and prepared calls ready for signing\n */\nexport type PrepareSwapResult = Extract<\n RequestQuoteV0Result,\n { rawCalls?: false | undefined }\n>;\n\n/**\n * Hook result for preparing swaps\n */\nexport interface UsePrepareSwapResult {\n /** Whether the swap is being prepared */\n isLoading: boolean;\n\n /** Error if preparation failed */\n error: Error | null;\n\n /** Prepared swap data if successful */\n data: PrepareSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Request a swap quote and prepare calls */\n prepareSwap(request: PrepareSwapRequest): Promise<PrepareSwapResult>;\n}\n\n/**\n * Result of submitting a swap\n * Simplified wrapper that extracts the transaction hash\n */\nexport interface SubmitSwapResult {\n /** Transaction hash of the swap */\n txnHash: Hash;\n}\n\n/**\n * Hook result for submitting swaps\n */\nexport interface UseSubmitSwapResult {\n /** Whether the swap is being submitted */\n isLoading: boolean;\n\n /** Error if submission failed */\n error: Error | null;\n\n /** Swap submission result if successful */\n data: SubmitSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Sign and submit prepared swap calls */\n submitSwap(preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import type { Address, Hash, Hex } from \"viem\";\nimport type { swapActions } from \"@account-kit/wallet-client/experimental\";\nimport { ConnectionConfigSchema } from \"@aa-sdk/core\";\nimport type { z } from \"zod\";\n\n/**\n * Configuration for the Alchemy provider\n * Uses ConnectionConfigSchema to ensure valid transport configuration\n */\nexport type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {\n /** Policy ID(s) for gas sponsorship */\n policyId?: string | string[];\n\n /**\n * Set to true to disable gas sponsorship by default\n * Default: false (sponsorship enabled when policyId is provided)\n */\n disableSponsorship?: boolean;\n};\n\n/**\n * Unsigned transaction request\n */\nexport interface UnsignedTransactionRequest {\n /** Recipient address */\n to: Address;\n\n /** Transaction data (calldata) */\n data?: Hex;\n\n /** Transaction value - accepts string | number | bigint */\n value?: string | number | bigint;\n}\n\n/**\n * Options for sending a transaction\n */\nexport interface SendTransactionOptions {\n /**\n * Set to true to disable sponsorship for this specific transaction\n * Default: false (follows provider's disableSponsorship setting)\n */\n disableSponsorship?: boolean;\n}\n\n/**\n * Result of a successful transaction\n */\nexport interface SendTransactionResult {\n /** EVM transaction hash (first receipt hash) */\n txnHash: Hash;\n}\n\n/**\n * Hook result for sending transactions\n */\nexport interface UseSendTransactionResult {\n /** Whether the transaction is currently being sent */\n isLoading: boolean;\n\n /** Error if transaction failed */\n error: Error | null;\n\n /** Transaction result if successful */\n data: SendTransactionResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Send a single transaction or batch of transactions */\n sendTransaction(\n input: UnsignedTransactionRequest | UnsignedTransactionRequest[],\n options?: SendTransactionOptions,\n ): Promise<SendTransactionResult>;\n}\n\n/**\n * Request parameters for preparing a swap\n * Derived directly from the SDK to ensure type safety\n *\n * Note: Provide either `fromAmount` OR `minimumToAmount`, not both.\n * - Use `fromAmount` to specify exact amount to swap FROM\n * - Use `minimumToAmount` to specify minimum amount to receive TO\n */\nexport type PrepareSwapRequest = Parameters<\n ReturnType<typeof swapActions>[\"requestQuoteV0\"]\n>[0];\n\n/**\n * Response from requestQuoteV0\n * Derived directly from the SDK to ensure type safety\n */\nexport type RequestQuoteV0Result = Awaited<\n ReturnType<ReturnType<typeof swapActions>[\"requestQuoteV0\"]>\n>;\n\n/**\n * Swap quote information extracted from prepared swap calls\n * Derived directly from the SDK response\n */\nexport type SwapQuote = NonNullable<RequestQuoteV0Result[\"quote\"]>;\n\n/**\n * Result of preparing a swap (full response from requestQuoteV0)\n * Contains quote and prepared calls ready for signing\n */\nexport type PrepareSwapResult = Extract<\n RequestQuoteV0Result,\n { rawCalls?: false | undefined }\n>;\n\n/**\n * Hook result for preparing swaps\n */\nexport interface UsePrepareSwapResult {\n /** Whether the swap is being prepared */\n isLoading: boolean;\n\n /** Error if preparation failed */\n error: Error | null;\n\n /** Prepared swap data if successful */\n data: PrepareSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Request a swap quote and prepare calls */\n prepareSwap(request: PrepareSwapRequest): Promise<PrepareSwapResult>;\n}\n\n/**\n * Result of submitting a swap\n * Simplified wrapper that extracts the transaction hash\n */\nexport interface SubmitSwapResult {\n /** Transaction hash of the swap */\n txnHash: Hash;\n}\n\n/**\n * Hook result for submitting swaps\n */\nexport interface UseSubmitSwapResult {\n /** Whether the swap is being submitted */\n isLoading: boolean;\n\n /** Error if submission failed */\n error: Error | null;\n\n /** Swap submission result if successful */\n data: SubmitSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Sign and submit prepared swap calls */\n submitSwap(preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult>;\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.68.0";
1
+ export declare const VERSION = "4.70.0";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.68.0";
3
+ export const VERSION = "4.70.0";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.68.0\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.70.0\";\n"]}
@@ -1,11 +1,12 @@
1
1
  import type { UseSendTransactionResult } from "../types";
2
2
  /**
3
3
  * Hook to send transactions with optional gas sponsorship via Alchemy
4
+ * Supports both single transactions and batch transactions
4
5
  * Drop-in alternative to Privy's useSendTransaction hook
5
6
  *
6
7
  * @returns {UseSendTransactionResult} Hook result with sendTransaction function and state
7
8
  *
8
- * @example
9
+ * @example Single transaction
9
10
  * ```tsx
10
11
  * const { sendTransaction, isLoading, error, data } = useAlchemySendTransaction();
11
12
  *
@@ -22,6 +23,16 @@ import type { UseSendTransactionResult } from "../types";
22
23
  * }
23
24
  * };
24
25
  * ```
26
+ *
27
+ * @example Batch transactions
28
+ * ```tsx
29
+ * const { sendTransaction } = useAlchemySendTransaction();
30
+ *
31
+ * const result = await sendTransaction([
32
+ * { to: '0x...', data: '0x...', value: '1000000000000000000' },
33
+ * { to: '0x...', data: '0x...' },
34
+ * ]);
35
+ * ```
25
36
  */
26
37
  export declare function useAlchemySendTransaction(): UseSendTransactionResult;
27
38
  //# sourceMappingURL=useAlchemySendTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAlchemySendTransaction.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIV,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAuBlB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,yBAAyB,IAAI,wBAAwB,CAsGpE"}
1
+ {"version":3,"file":"useAlchemySendTransaction.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIV,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAuBlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,yBAAyB,IAAI,wBAAwB,CAuGpE"}
@@ -55,8 +55,8 @@ export interface UseSendTransactionResult {
55
55
  data: SendTransactionResult | null;
56
56
  /** Reset the hook state */
57
57
  reset(): void;
58
- /** Send a transaction */
59
- sendTransaction(input: UnsignedTransactionRequest, options?: SendTransactionOptions): Promise<SendTransactionResult>;
58
+ /** Send a single transaction or batch of transactions */
59
+ sendTransaction(input: UnsignedTransactionRequest | UnsignedTransactionRequest[], options?: SendTransactionOptions): Promise<SendTransactionResult>;
60
60
  }
61
61
  /**
62
62
  * Request parameters for preparing a swap
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,GAAG;IAC3E,uCAAuC;IACvC,Q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.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@account-kit/privy-integration",
3
- "version": "4.68.0",
3
+ "version": "4.70.0",
4
4
  "description": "Use Alchemy gas sponsorship, swaps and more with Privy",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -43,8 +43,8 @@
43
43
  "typescript-template": "*"
44
44
  },
45
45
  "dependencies": {
46
- "@account-kit/infra": "^4.68.0",
47
- "@account-kit/wallet-client": "^4.68.0"
46
+ "@account-kit/infra": "^4.70.0",
47
+ "@account-kit/wallet-client": "^4.70.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@privy-io/react-auth": "^2.3.1 || ^3.0.0",
@@ -62,5 +62,5 @@
62
62
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
63
63
  },
64
64
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
65
- "gitHead": "f95d7f917b6d5b6ef9fa53a2bcaa658bd6aa6673"
65
+ "gitHead": "c4be4fe2e524d257bbea8b0a7aa130237f115191"
66
66
  }
@@ -33,11 +33,12 @@ function normalizeValue(value: string | number | bigint): Hex {
33
33
 
34
34
  /**
35
35
  * Hook to send transactions with optional gas sponsorship via Alchemy
36
+ * Supports both single transactions and batch transactions
36
37
  * Drop-in alternative to Privy's useSendTransaction hook
37
38
  *
38
39
  * @returns {UseSendTransactionResult} Hook result with sendTransaction function and state
39
40
  *
40
- * @example
41
+ * @example Single transaction
41
42
  * ```tsx
42
43
  * const { sendTransaction, isLoading, error, data } = useAlchemySendTransaction();
43
44
  *
@@ -54,6 +55,16 @@ function normalizeValue(value: string | number | bigint): Hex {
54
55
  * }
55
56
  * };
56
57
  * ```
58
+ *
59
+ * @example Batch transactions
60
+ * ```tsx
61
+ * const { sendTransaction } = useAlchemySendTransaction();
62
+ *
63
+ * const result = await sendTransaction([
64
+ * { to: '0x...', data: '0x...', value: '1000000000000000000' },
65
+ * { to: '0x...', data: '0x...' },
66
+ * ]);
67
+ * ```
57
68
  */
58
69
  export function useAlchemySendTransaction(): UseSendTransactionResult {
59
70
  const { getClient } = useAlchemyClient();
@@ -66,7 +77,7 @@ export function useAlchemySendTransaction(): UseSendTransactionResult {
66
77
 
67
78
  const sendTransaction = useCallback(
68
79
  async (
69
- input: UnsignedTransactionRequest,
80
+ input: UnsignedTransactionRequest | UnsignedTransactionRequest[],
70
81
  options?: SendTransactionOptions,
71
82
  ): Promise<SendTransactionResult> => {
72
83
  setIsLoading(true);
@@ -84,12 +95,13 @@ export function useAlchemySendTransaction(): UseSendTransactionResult {
84
95
  ? !options.disableSponsorship
85
96
  : hasPolicyId && enableSponsorship;
86
97
 
87
- // Format the transaction call
88
- const formattedCall = {
89
- to: input.to,
90
- data: input.data,
91
- value: input.value ? normalizeValue(input.value) : undefined,
92
- };
98
+ // Format the transaction call(s)
99
+ const inputs = Array.isArray(input) ? input : [input];
100
+ const formattedCalls = inputs.map((txn) => ({
101
+ to: txn.to,
102
+ data: txn.data,
103
+ value: txn.value ? normalizeValue(txn.value) : undefined,
104
+ }));
93
105
 
94
106
  // Build capabilities based on sponsorship
95
107
  const policyId = Array.isArray(config.policyId)
@@ -105,10 +117,10 @@ export function useAlchemySendTransaction(): UseSendTransactionResult {
105
117
  capabilities.paymasterService = { policyId };
106
118
  }
107
119
 
108
- // Send the transaction
120
+ // Send the transaction(s)
109
121
  const result = await client.sendCalls({
110
122
  from: embeddedWallet.address as Address,
111
- calls: [formattedCall],
123
+ calls: formattedCalls,
112
124
  capabilities,
113
125
  });
114
126
 
package/src/types.ts CHANGED
@@ -67,9 +67,9 @@ export interface UseSendTransactionResult {
67
67
  /** Reset the hook state */
68
68
  reset(): void;
69
69
 
70
- /** Send a transaction */
70
+ /** Send a single transaction or batch of transactions */
71
71
  sendTransaction(
72
- input: UnsignedTransactionRequest,
72
+ input: UnsignedTransactionRequest | UnsignedTransactionRequest[],
73
73
  options?: SendTransactionOptions,
74
74
  ): Promise<SendTransactionResult>;
75
75
  }
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.66.4";
3
+ export const VERSION = "4.70.0";