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
_26import { MetaTransactionData } from '@safe-global/types-kit'_26import { safeOperationsClient } from './setup.ts'_26_26const 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_26const 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.
_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.setupEstimation
(Optional)
- Type:
EstimateFeeFunction
Function called before eth_estimateUserOperationGas
.
_10const safeOperationResult = await safeOperationsClient.sendSafeOperation({_10 transactions,_10 feeEstimator: {_10 setupEstimation_10 }_10})
feeEstimator.adjustEstimation
(Optional)
- Type:
EstimateFeeFunction
Function called after eth_estimateUserOperationGas
.
_10const 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.
_10const safeOperationResult = await safeOperationsClient.sendSafeOperation({_10 transactions,_10 feeEstimator: {_10 getPaymasterEstimation_10 }_10})