UserOperation.from
Instantiates a UserOperation.UserOperation
from a provided input.
Imports
Named
import { UserOperation } from 'ox/erc4337'
Examples
import { Value } from 'ox'
import { UserOperation } from 'ox/erc4337'
const userOperation = UserOperation.from({
callData: '0xdeadbeef',
callGasLimit: 300_000n,
maxFeePerGas: Value.fromGwei('20'),
maxPriorityFeePerGas: Value.fromGwei('2'),
nonce: 69n,
preVerificationGas: 100_000n,
sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
verificationGasLimit: 100_000n,
})
Attaching Signatures
import { Secp256k1, Value } from 'ox'
import { UserOperation } from 'ox/erc4337'
const userOperation = UserOperation.from({
callData: '0xdeadbeef',
callGasLimit: 300_000n,
maxFeePerGas: Value.fromGwei('20'),
maxPriorityFeePerGas: Value.fromGwei('2'),
nonce: 69n,
preVerificationGas: 100_000n,
sender: '0x9f1fdab6458c5fc642fa0f4c5af7473c46837357',
verificationGasLimit: 100_000n,
})
const payload = UserOperation.getSignPayload(userOperation, {
chainId: 1,
entryPointAddress: '0x1234567890123456789012345678901234567890',
entryPointVersion: '0.7',
})
const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
const userOperation_signed = UserOperation.from(userOperation, { signature })
Definition
function from<userOperation, signature>(
userOperation: userOperation | UserOperation,
options?: from.Options<signature>,
): from.ReturnType<userOperation, signature>
Source: src/erc4337/UserOperation.ts
Parameters
userOperation
- Type:
userOperation | UserOperation
The user operation to instantiate.
options
- Type:
from.Options<signature>
- Optional
options.signature
- Type:
0x${string} | { r: bigint; s: bigint; yParity: number; } | signature
- Optional
Return Type
User Operation.
from.ReturnType<userOperation, signature>