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' )
}]
})
Hoisted account
If you do not want to pass an account to every call, hoist the account on the Bundler Client instead (see config.ts below).
import { parseEther } from 'viem'
import { bundlerClient } from './config'
const gas = await bundlerClient . estimateUserOperationGas ({
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}]
})
Advanced Contract Integration
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.
[example.ts]
[abi.ts]
[config.ts]
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' ,
}],
})
Response Architecture
The Abstraxn gas estimation framework returns a comprehensive analysis structure optimized for strategic decision-making:
{
callGasLimit : bigint ;
preVerificationGas : bigint ;
verificationGasLimit : bigint ;
paymasterVerificationGasLimit : bigint | undefined ;
paymasterPostOpGasLimit : bigint | undefined ;
}
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
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)
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: 69420 n ,
})
factory (optional)
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)
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)
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: 420 n ,
})
maxPriorityFeePerGas (optional)
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: 420 n ,
maxFeePerGas: 10 n ,
})
nonce (optional)
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: 10 n ,
})
paymaster (optional)
Type: Address | true | PaymasterClient | PaymasterActions
Comprehensive sponsorship configuration framework supporting multiple integration strategies:
Address Configuration : Direct paymaster contract integration for streamlined sponsorship
PaymasterClient Integration : Advanced client-based sponsorship with enhanced functionality
Bundler Integration : Unified bundler-paymaster architecture for simplified implementation
Custom Function Support : Flexible sponsorship logic through specialized function implementations
Strategic Paymaster Contract Integration
import { account , bundlerClient } from './config'
// ---cut---
const hash = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
paymaster: '0x942fD5017c0F60575930D8574Eaca13BEcD6e1bB' ,
paymasterData: '0xdeadbeef' ,
})
Advanced Paymaster Client Architecture
import { account , bundlerClient } from './config'
// ---cut---
import { http , parseEther } from 'viem'
import { createPaymasterClient } from 'viem/account-abstraction'
const paymasterClient = createPaymasterClient ({
transport: http ( 'https://bundler.abstraxn.com/api/v1/{CHAIN_ID}/?apikey={API_KEY}' )
})
const hash = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
paymaster: paymasterClient ,
})
Unified Bundler-Paymaster Approach
import { account , bundlerClient } from './config'
// ---cut---
const hash = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
paymaster: true ,
})
paymasterContext (optional)
Specialized configuration parameters for advanced paymaster integration scenarios.
This parameter maintains relevance exclusively within PaymasterClient-based architectures, supporting sophisticated sponsorship workflows.
import { account , bundlerClient } from './config'
// ---cut---
import { http , parseEther } from 'viem'
import { createPaymasterClient } from 'viem/account-abstraction'
const paymasterClient = createPaymasterClient ({
transport: http ( 'https://bundler.abstraxn.com/api/v1/{CHAIN_ID}/?apikey={API_KEY}' )
})
const hash = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
paymaster: paymasterClient ,
paymasterContext: {
policyId: 'abc123'
},
})
paymasterData (optional)
Structured execution instructions for paymaster contract interactions.
This configuration applies specifically to address-based paymaster implementations, enabling direct contract communication.
import { parseEther } from 'viem'
import { account , bundlerClient } from './config'
// ---cut---
const gas = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
paymaster: '0x942fD5017c0F60575930D8574Eaca13BEcD6e1bB' ,
paymasterData: '0xdeadbeef' ,
})
paymasterPostOpGasLimit (optional)
Strategic resource allocation for post-operation paymaster logic execution.
import { parseEther } from 'viem'
import { account , bundlerClient } from './config'
// ---cut---
const gas = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
paymaster: '0x942fD5017c0F60575930D8574Eaca13BEcD6e1bB' ,
paymasterData: '0xdeadbeef' ,
paymasterPostOpGasLimit: 69420 n ,
})
paymasterVerificationGasLimit (optional)
Precision gas allocation for paymaster validation procedures within the Abstraxn framework.
import { parseEther } from 'viem'
import { account , bundlerClient } from './config'
// ---cut---
const gas = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
paymaster: '0x942fD5017c0F60575930D8574Eaca13BEcD6e1bB' ,
paymasterData: '0xdeadbeef' ,
paymasterVerificationGasLimit: 69420 n ,
})
preVerificationGas (optional)
Strategic bundler compensation configuration, ensuring sustainable operation 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' )
}],
preVerificationGas: 69420 n ,
})
signature (optional)
Authentication signature for User Operation validation, supporting secure transaction execution.
import { parseEther } from 'viem'
import { account , bundlerClient } from './config'
// ---cut---
const gas = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
signature: '0x...' ,
})
stateOverride (optional)
Advanced state manipulation framework enabling sophisticated testing and simulation scenarios 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' )
}],
stateOverride: [
{
address: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC' ,
balance: parseEther ( '1' ),
stateDiff: [
{
slot: '0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0' ,
value: '0x00000000000000000000000000000000000000000000000000000000000001a4' ,
},
],
}
],
})
verificationGasLimit (optional)
Strategic resource allocation for comprehensive verification procedures, ensuring robust security within User Operation execution.
import { parseEther } from 'viem'
import { account , bundlerClient } from './config'
// ---cut---
const gas = await bundlerClient . estimateUserOperationGas ({
account ,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' ,
value: parseEther ( '1' )
}],
verificationGasLimit: 69420 n ,
})