API Kit Reference
addSafeOperation

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.


_29
import { AddSafeOperationProps } from '@safe-global/api-kit'
_29
import { apiKit } from './setup.ts'
_29
_29
const 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
_29
const 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
_29
await apiKit.addSafeOperation(config)

Parameters

entryPoint

  • Type: string

Address of the EntryPoint contract.


_10
await apiKit.addSafeOperation({
_10
entryPoint: '0x...',
_10
moduleAddress: '0x...',
_10
safeAddress: '0x...',
_10
userOperation
_10
})

moduleAddress

  • Type: string

Address of the Safe4337Module contract.


_10
await 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.


_10
await apiKit.addSafeOperation({
_10
entryPoint: '0x...',
_10
moduleAddress: '0x...',
_10
safeAddress: '0x...',
_10
userOperation
_10
})

safeOperation.sender

  • Type: string

_18
await 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

_18
await 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

_18
await 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

_18
await 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

_18
await 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

_18
await 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

_18
await 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

_18
await 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

_18
await 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

_18
await 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

_18
await 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.


_10
await 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.


_10
await apiKit.addSafeOperation({
_10
entryPoint: '0x...',
_10
moduleAddress: '0x...',
_10
safeAddress: '0x...',
_10
userOperation,
_10
options: {
_10
validUntil: currentTimestamp + 60_000
_10
}
_10
})

Was this page helpful?