addSafeOperation
Adds a new ERC-4337 Safe operation for a given Safe account.
Usage
A Safe operation can be created by using the createTransaction method from the Safe4337Pack
.
_29import { AddSafeOperationProps } from '@safe-global/api-kit'_29import { apiKit } from './setup.ts'_29_29const userOperation = {_29 sender: '0x...',_29 nonce: '10',_29 initCode: '0x...',_29 callData: '0x...',_29 callGasLimit: 123n,_29 verificationGasLimit: 123n,_29 preVerificationGas: 123n,_29 maxFeePerGas: 123n,_29 maxPriorityFeePerGas: 123n,_29 paymasterAndData: '0x...',_29 signature: '0x...'_29}_29_29const config: AddSafeOperationProps = {_29 entryPoint: '0x...',_29 moduleAddress: '0x...',_29 safeAddress: '0x...',_29 userOperation,_29 options: { // Optional_29 validAfter: currentTimestamp - 60_000, // Optional_29 validUntil: currentTimestamp + 60_000 // Optional_29 }_29}_29_29await apiKit.addSafeOperation(config)
Parameters
entryPoint
- Type:
string
Address of the EntryPoint
contract.
_10await apiKit.addSafeOperation({_10 entryPoint: '0x...',_10 moduleAddress: '0x...',_10 safeAddress: '0x...',_10 userOperation_10 })
moduleAddress
- Type:
string
Address of the Safe4337Module
contract.
_10await apiKit.addSafeOperation({_10 entryPoint: '0x...',_10 moduleAddress: '0x...',_10 safeAddress: '0x...',_10 userOperation_10 })
safeAddress
- Type:
string
Address of the Safe to add a Safe operation for.
_10await apiKit.addSafeOperation({_10 entryPoint: '0x...',_10 moduleAddress: '0x...',_10 safeAddress: '0x...',_10 userOperation_10 })
safeOperation.sender
- Type:
string
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.nonce
- Type:
string
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.initCode
- Type:
string
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.callData
- Type:
string
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.callGasLimit
- Type:
bigint
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.verificationGasLimit
- Type:
bigint
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.preVerificationGas
- Type:
bigint
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.maxFeePerGas
- Type:
bigint
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.maxPriorityFeePerGas
- Type:
bigint
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.paymasterAndData
- Type:
string
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
safeOperation.signature
- Type:
string
_18await apiKit.addSafeOperation({_18 entryPoint: '0x...',_18 moduleAddress: '0x...',_18 safeAddress: '0x...',_18 userOperation: {_18 sender: '0x...',_18 nonce: '10',_18 initCode: '0x...',_18 callData: '0x...',_18 callGasLimit: 123n,_18 verificationGasLimit: 123n,_18 preVerificationGas: 123n,_18 maxFeePerGas: 123n,_18 maxPriorityFeePerGas: 123n,_18 paymasterAndData: '0x...',_18 signature: '0x...'_18 }_18})
options.validAfter
(Optional)
- Type:
number
The user operation will be valid after this block's timestamp.
_10await apiKit.addSafeOperation({_10 entryPoint: '0x...',_10 moduleAddress: '0x...',_10 safeAddress: '0x...',_10 userOperation,_10 options: {_10 validAfter: currentTimestamp - 60_000_10 }_10})
options.validUntil
(Optional)
- Type:
number
The user operation will remain valid until this block's timestamp.
_10await apiKit.addSafeOperation({_10 entryPoint: '0x...',_10 moduleAddress: '0x...',_10 safeAddress: '0x...',_10 userOperation,_10 options: {_10 validUntil: currentTimestamp + 60_000_10 }_10})