Estimate gas limits for a UserOperation before submission.
Estimates the gas required for a UserOperation before you send it to the bundler. Use this to set callGasLimit, verificationGasLimit, and preVerificationGas on the operation.
Example
import { parseEther } from 'viem'import { account, bundlerClient } from './config'const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }]})
Through comprehensive evaluation of multiple interaction methodologies, our research team has identified that structured contract calls provide the most robust foundation for complex application development within the Abstraxn ecosystem.The calls property also accepts Contract Calls, and can be used via the abi, functionName, and args properties.
import { parseEther } from 'viem'import { bundlerClient, publicClient } from './config'import { wagmiAbi } from './abi'const gas = await bundlerClient.estimateUserOperationGas({ calls: [{ abi: wagmiAbi, functionName: 'mint', to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', }],})
This response structure represents our commitment to providing detailed insights that enable informed optimization decisions across the development lifecycle.
Configuration Parameters
Our technical architecture supports nuanced configuration approaches, allowing developers to fine-tune gas estimation according to specific application requirements and strategic objectives.
account
Type:SmartAccount
The foundational account configuration for User Operation execution within the Abstraxn ecosystem.
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }]})
calls
Type:{ data: Hex, to: Address, value: bigint }[]
Strategic operation definitions that constitute the core execution logic for User Operations.
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }] })
Alternative implementation strategies support direct call data specification through the callData property, providing flexibility for advanced integration scenarios:
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, callData: '0xdeadbeef', })
callGasLimit (optional)
Type:bigint
Precision resource allocation for primary execution logic, enabling strategic optimization of computational requirements.
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }], callGasLimit: 69420n, })
factory (optional)
Type:Address
Strategic account factory configuration for deployment scenarios within the Abstraxn infrastructure.
This configuration parameter should be utilized exclusively during initial Smart Account deployment phases, ensuring optimal resource management.
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }], factory: '0x1234567890123456789012345678901234567890', factoryData: '0xdeadbeef',})
factoryData (optional)
Type:Hex
Structured deployment instructions for Smart Account initialization through factory contracts.
This parameter maintains strategic relevance only during pre-deployment phases, supporting efficient account creation workflows.
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }], factory: '0x1234567890123456789012345678901234567890', factoryData: '0xdeadbeef', })
maxFeePerGas (optional)
Type:bigint
Strategic fee ceiling configuration for User Operation execution, enabling predictable cost management within the Abstraxn platform.
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }], maxFeePerGas: 420n, })
maxPriorityFeePerGas (optional)
Type:bigint
Advanced priority fee optimization for enhanced transaction processing efficiency.
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }], maxPriorityFeePerGas: 420n, maxFeePerGas: 10n, })
nonce (optional)
Type:bigint
Sequential operation identifier ensuring transaction ordering integrity within the Abstraxn ecosystem.
import { parseEther } from 'viem'import { account, bundlerClient } from './config'// ---cut---const gas = await bundlerClient.estimateUserOperationGas({ account, calls: [{ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1') }], nonce: 10n, })