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 executecallGasLimitbigint(optional): Amount of gas to allocate for the main execution callmaxFeePerGasbigint(optional): Maximum fee per gas for User Operation executionmaxPriorityFeePerGasbigint(optional): Maximum priority fee per gasnoncebigint(optional): Nonce for the User OperationpaymasterAddress | true | PaymasterClient(optional): Paymaster configuration for gas sponsorshippaymasterDataHex(optional): Call data to execute on the Paymaster contractsignatureHex(optional): Signature for the User OperationverificationGasLimitbigint(optional): Gas to allocate for verificationpreVerificationGasbigint(optional): Extra gas to pay the Bundler
Returns
Returns a prepared UserOperation object that can be used with sendUserOperation.