Starter Kit Reference
sendSafeOperation

sendSafeOperation

If the threshold of the connected Safe is greater than 1, it will create the Safe operation and store it in the Safe Transaction Service to collect the signatures from the Safe owners.

If the threshold of the connected Safe is 1, the Safe operation will be sent to the bundler and executed immediately.

If the Safe account is not deployed, it will be deployed when this method is called and funds will be required if the transaction is not sponsored by a paymaster.

Usage


_26
import { MetaTransactionData } from '@safe-global/types-kit'
_26
import { safeOperationsClient } from './setup.ts'
_26
_26
const transactions: MetaTransactionData[] = [{
_26
to: '0x...',
_26
value: '0',
_26
data: '0x'
_26
operation: 1 // Optional
_26
}, {
_26
to: '0x...',
_26
value: '0',
_26
data: '0x',
_26
operation: 1 // Optional
_26
}]
_26
_26
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_26
transactions,
_26
validAfter: Number(timestamp - 60_000n), // Optional
_26
validUntil: Number(timestamp + 60_000n), // Optional
_26
amountToApprove: 123n, // Optional
_26
feeEstimator: {
_26
setupEstimation, // Optional
_26
adjustEstimation, // Optional
_26
getPaymasterEstimation // Optional
_26
}
_26
})

Returns

Promise<SafeClientResult>

The result of the Safe operation sent.

Parameters

transactions.to

  • Type: string

The address of the recipient.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions: [{
_10
to: '0x...',
_10
value: '123',
_10
data: '0x'
_10
}]
_10
})

transactions.value

  • Type: string

The amount of native tokens that are transferred.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions: [{
_10
to: '0x...',
_10
value: '123',
_10
data: '0x'
_10
}]
_10
})

transactions.data

  • Type: string

The encoded transaction data.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions: [{
_10
to: '0x...',
_10
value: '123',
_10
data: '0x'
_10
}]
_10
})

transactions.operation (Optional)

  • Type: OperationType

  • Default: 1

The operation of the Safe transaction.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions: [{
_10
to: '0x...',
_10
value: '123',
_10
data: '0x',
_10
operation: 0
_10
}]
_10
})

amountToApprove (Optional)

  • Type: bigint

The amount to approve for the Safe operation.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions,
_10
ammountToApprove
_10
})

validAfter (Optional)

  • Type: number

The timestamp after which the Safe operation is valid.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions,
_10
validAfter: Number(timestamp - 60_000n)
_10
})

validUntil (Optional)

  • Type: number

The timestamp until which the Safe operation is valid.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions,
_10
validUntil: Number(timestamp + 60_000n)
_10
})

feeEstimator.setupEstimation (Optional)

  • Type: EstimateFeeFunction

Function called before eth_estimateUserOperationGas.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions,
_10
feeEstimator: {
_10
setupEstimation
_10
}
_10
})

feeEstimator.adjustEstimation (Optional)

  • Type: EstimateFeeFunction

Function called after eth_estimateUserOperationGas.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions,
_10
feeEstimator: {
_10
adjustEstimation
_10
}
_10
})

feeEstimator.getPaymasterEstimation (Optional)

  • Type: EstimateSponsoredFeeFunction

Function called if the Safe operation is sponsored to adjust the paymasterAndData property.


_10
const safeOperationResult = await safeOperationsClient.sendSafeOperation({
_10
transactions,
_10
feeEstimator: {
_10
getPaymasterEstimation
_10
}
_10
})

Was this page helpful?