@@ -7,6 +7,12 @@ import {
77 type ExecuteReturnType ,
88 execute ,
99} from '../actions/execute.js'
10+ import {
11+ type Batch ,
12+ type ExecuteBatchesParameters ,
13+ type ExecuteBatchesReturnType ,
14+ executeBatches ,
15+ } from '../actions/executeBatches.js'
1016import {
1117 type SupportsExecutionModeParameters ,
1218 type SupportsExecutionModeReturnType ,
@@ -91,6 +97,108 @@ export type Erc7821Actions<
9197 > (
9298 parameters : ExecuteParameters < calls , chain , account , chainOverride > ,
9399 ) => Promise < ExecuteReturnType >
100+ /**
101+ * Executes batches of call(s) using "batch of batches" mode on an [ERC-7821-compatible contract](https://eips.ethereum.org/EIPS/eip-7821).
102+ *
103+ * @example
104+ * ```ts
105+ * import { createClient, http, parseEther } from 'viem'
106+ * import { privateKeyToAccount } from 'viem/accounts'
107+ * import { mainnet } from 'viem/chains'
108+ * import { erc7821Actions } from 'viem/experimental'
109+ *
110+ * const account = privateKeyToAccount('0x...')
111+ *
112+ * const client = createClient({
113+ * chain: mainnet,
114+ * transport: http(),
115+ * }).extend(erc7821Actions())
116+ *
117+ * const hash = await client.executeBatches({
118+ * account,
119+ * batches: [
120+ * {
121+ * calls: [
122+ * {
123+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
124+ * value: parseEther('1'),
125+ * },
126+ * ],
127+ * },
128+ * {
129+ * calls: [
130+ * {
131+ * to: '0xcb98643b8786950F0461f3B0edf99D88F274574D',
132+ * value: parseEther('2'),
133+ * },
134+ * {
135+ * data: '0xdeadbeef',
136+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
137+ * },
138+ * ],
139+ * },
140+ * ],
141+ * to: account.address,
142+ * })
143+ * ```
144+ *
145+ * @example
146+ * ```ts
147+ * // Account Hoisting
148+ * import { createClient, http, parseEther } from 'viem'
149+ * import { privateKeyToAccount } from 'viem/accounts'
150+ * import { mainnet } from 'viem/chains'
151+ * import { erc7821Actions } from 'viem/experimental'
152+ *
153+ * const account = privateKeyToAccount('0x...')
154+ *
155+ * const client = createClient({
156+ * chain: mainnet,
157+ * transport: http(),
158+ * }).extend(erc7821Actions())
159+ *
160+ * const hash = await client.executeBatches({
161+ * batches: [
162+ * {
163+ * calls: [
164+ * {
165+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
166+ * value: parseEther('1'),
167+ * },
168+ * ],
169+ * },
170+ * {
171+ * calls: [
172+ * {
173+ * to: '0xcb98643b8786950F0461f3B0edf99D88F274574D',
174+ * value: parseEther('2'),
175+ * },
176+ * {
177+ * data: '0xdeadbeef',
178+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
179+ * },
180+ * ],
181+ * },
182+ * ],
183+ * to: account.address,
184+ * })
185+ * ```
186+ *
187+ * @param client - Client to use.
188+ * @param parameters - {@link ExecuteBatchesParameters}
189+ * @returns Transaction hash. {@link ExecuteBatchesReturnType}
190+ */
191+ executeBatches : <
192+ const batches extends readonly Batch [ ] ,
193+ chainOverride extends Chain | undefined = undefined ,
194+ > (
195+ parameters : ExecuteBatchesParameters <
196+ batches ,
197+ chain ,
198+ account ,
199+ chainOverride
200+ > ,
201+ ) => Promise < ExecuteBatchesReturnType >
94202 /**
95203 * Checks if the contract supports the ERC-7821 execution mode.
96204 *
@@ -142,6 +250,7 @@ export function erc7821Actions() {
142250 ) : Erc7821Actions < chain , account > => {
143251 return {
144252 execute : ( parameters ) => execute ( client , parameters ) ,
253+ executeBatches : ( parameters ) => executeBatches ( client , parameters ) ,
145254 supportsExecutionMode : ( parameters ) =>
146255 supportsExecutionMode ( client , parameters ) ,
147256 }
0 commit comments