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
_25import { MetaTransactionData } from '@safe-global/types-kit'_25import { safeOperationsClient } from './setup.ts'_25_25const transactions: MetaTransactionData[] = [{_25 to: '0x...',_25 value: '0',_25 data: '0x'_25 operation: 1 // Optional_25}, {_25 to: '0x...',_25 value: '0',_25 data: '0x',_25 operation: 1 // Optional_25}]_25_25const safeOperationResult = await safeOperationsClient.sendSafeOperation({_25 transactions,_25 validAfter: Number(timestamp - 60_000n), // Optional_25 validUntil: Number(timestamp + 60_000n), // Optional_25 amountToApprove: 123n, // Optional_25 feeEstimator: {_25 preEstimateUserOperationGas, // Optional_25 postEstimateUserOperationGas, // Optional_25 }_25})
Returns
Promise<SafeClientResult>
The result of the Safe operation sent.
Parameters
transactions.to
- Type:
string
The address of the recipient.
_10const 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.
_10const 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.
_10const 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.
_10const 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.
_10const safeOperationResult = await safeOperationsClient.sendSafeOperation({_10 transactions,_10 ammountToApprove_10})
validAfter
(Optional)
- Type:
number
The timestamp after which the Safe operation is valid.
_10const 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.
_10const safeOperationResult = await safeOperationsClient.sendSafeOperation({_10 transactions,_10 validUntil: Number(timestamp + 60_000n)_10})
feeEstimator.preEstimateUserOperationGas
(Optional)
- Type:
EstimateFeeFunction
Function called before eth_estimateUserOperationGas
to setup the User operation for gas estimation.
_10const safeOperationResult = await safeOperationsClient.sendSafeOperation({_10 transactions,_10 feeEstimator: {_10 preEstimateUserOperationGas_10 }_10})
feeEstimator.postEstimateUserOperationGas
(Optional)
- Type:
EstimateFeeFunction
Function called after eth_estimateUserOperationGas
to adjust the User operations with the result of the gas estimation.
_10const safeOperationResult = await safeOperationsClient.sendSafeOperation({_10 transactions,_10 feeEstimator: {_10 postEstimateUserOperationGas_10 }_10})