@@ -246,13 +246,47 @@ export function useParaEIP7702Transaction() {
246246 // Step 6: Send UserOperation with Alchemy gas sponsorship
247247 console . log ( '🔄 [EIP-7702] Sending UserOperation via Alchemy...' ) ;
248248
249- const userOperationResult = await alchemyClient . sendUserOperation ( {
250- uo : [ {
251- target : EIP7702_CONFIG . USDC_CONTRACT ,
252- data : transferData ,
253- value : BigInt ( 0 ) ,
254- } ] ,
255- } ) ;
249+ let userOperationResult ;
250+ try {
251+ // Try without gas multiplier first
252+ userOperationResult = await alchemyClient . sendUserOperation ( {
253+ uo : [ {
254+ target : EIP7702_CONFIG . USDC_CONTRACT ,
255+ data : transferData ,
256+ value : BigInt ( 0 ) ,
257+ } ] ,
258+ } ) ;
259+ } catch ( error : any ) {
260+ // Check if error is "replacement underpriced"
261+ const isUnderpricedError =
262+ error ?. message ?. includes ( 'replacement underpriced' ) ||
263+ error ?. details ?. includes ( 'replacement underpriced' ) ||
264+ error ?. shortMessage ?. includes ( 'replacement underpriced' ) ;
265+
266+ if ( isUnderpricedError ) {
267+ console . log ( '⚠️ [EIP-7702] Transaction underpriced, retrying with 20% gas increase...' ) ;
268+
269+ // Retry with 20% gas buffer
270+ userOperationResult = await alchemyClient . sendUserOperation ( {
271+ uo : [ {
272+ target : EIP7702_CONFIG . USDC_CONTRACT ,
273+ data : transferData ,
274+ value : BigInt ( 0 ) ,
275+ } ] ,
276+ overrides : {
277+ maxPriorityFeePerGas : {
278+ multiplier : 1.2 ,
279+ } ,
280+ maxFeePerGas : {
281+ multiplier : 1.2 ,
282+ } ,
283+ } ,
284+ } ) ;
285+ } else {
286+ // Re-throw other errors
287+ throw error ;
288+ }
289+ }
256290
257291 console . log ( '✅ [EIP-7702] UserOperation submitted:' , userOperationResult . hash ) ;
258292
0 commit comments