prepareUserOperation
This method prepares a User Operation for execution by filling in missing properties. It's useful when you want to construct a User Operation before sending it.
Usage
example.ts
import { nexusClient } from "./nexusClient"
import { parseEther } from "viem"
// Prepare a user operation
const userOperation = await nexusClient.prepareUserOperation({
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
}]
})
Parameters
calls
{ data?: Hex, to: Address, value?: bigint }[]
: Array of transactions to executecallGasLimit
bigint
(optional): Amount of gas to allocate for the main execution callmaxFeePerGas
bigint
(optional): Maximum fee per gas for User Operation executionmaxPriorityFeePerGas
bigint
(optional): Maximum priority fee per gasnonce
bigint
(optional): Nonce for the User Operationpaymaster
Address | true | PaymasterClient
(optional): Paymaster configuration for gas sponsorshippaymasterData
Hex
(optional): Call data to execute on the Paymaster contractsignature
Hex
(optional): Signature for the User OperationverificationGasLimit
bigint
(optional): Gas to allocate for verificationpreVerificationGas
bigint
(optional): Extra gas to pay the Bundler
Returns
Returns a prepared UserOperation
object that can be used with sendUserOperation
.