UserOperation.toInitCode
Converts a UserOperation.UserOperation to initCode.
Imports
Named
import { UserOperation } from 'ox/erc4337'Examples
import { Value } from 'ox'
import { UserOperation } from 'ox/erc4337'
const initCode = UserOperation.toInitCode({
authorization: {
address: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
chainId: 1,
nonce: 69n,
yParity: 0,
r: 1n,
s: 2n,
},
callData: '0xdeadbeef',
callGasLimit: 300_000n,
factory: '0x7702',
factoryData: '0xdeadbeef',
maxFeePerGas: Value.fromGwei('20'),
maxPriorityFeePerGas: Value.fromGwei('2'),
nonce: 69n,
preVerificationGas: 100_000n,
sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
})Definition
function toInitCode(
userOperation: UserOperation.UserOperation,
options?: toInitCode.Options,
): Hex.HexSource: src/erc4337/UserOperation.ts
Parameters
userOperation
The user operation to convert.
options
- Type:
toInitCode.Options - Optional
options.forHash
- Type:
boolean - Optional
Prepares the init code for hashing: replaces the EIP-7702 0x7702
marker with the delegate address.
Return Type
The init code.
Hex.Hex

