createTransaction
Returns a Safe transaction ready to be signed by the owners and executed.
This method supports batch transactions by passing an array of MetaTransactionData
objects with more than one element.
Usage
_25import { SafeTransactionOptionalProps } from '@safe-global/protocol-kit'_25import { MetaTransactionData, OperationType } from '@safe-global/types-kit'_25import { protocolKit } from './setup.ts'_25_25const transactions: MetaTransactionData[] = [{_25 to: '0x...',_25 value: '123',_25 data: '0x',_25 operation: OperationType.Call // Optional_25}]_25_25const options: SafeTransactionOptionalProps = {_25 safeTxGas: '123', // Optional_25 baseGas: '123', // Optional_25 gasPrice: '123', // Optional_25 gasToken: '0x...', // Optional_25 refundReceiver: '0x...', // Optional_25 nonce: 123 // Optional_25}_25_25const safeTransaction = await protocolKit.createTransaction({_25 transactions,_25 onlyCalls: true, // Optional_25 options // Optional_25})
Parameters
transactions.to
- Type:
string
The address of the recipient.
_10const safeTransaction = await protocolKit.createTransaction({_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 safeTransaction = await protocolKit.createTransaction({_10 transactions: [{_10 to: '0x...',_10 value: '123',_10 data: '0x'_10 }]_10})
transactions.data
- Type:
string
The encoded transaction data.
_10const safeTransaction = await protocolKit.createTransaction({_10 transactions: [{_10 to: '0x...',_10 value: '123',_10 data: '0x'_10 }]_10})
transactions.operation
(Optional)
- Type:
OperationType
- Default:
0
The operation of the Safe transaction. 0
for a Call and 1
for a DelegateCall.
_10const safeTransaction = await protocolKit.createTransaction({_10 transactions: [{_10 to: '0x...',_10 value: '123',_10 data: '0x',_10 operation: 0_10 }]_10})
onlyCalls
(Optional)
- Type:
boolean
- Default:
false
A boolean variable that forces the use of the MultiSendCallOnly
(opens in a new tab) contract instead of the MultiSend
(opens in a new tab) when sending a batch transaction.
_10const safeTransaction = await protocolKit.createTransaction(_10 '0x...',_10 onlyCalls: true_10)
options.safeTxGas
(Optional)
- Type:
string
The gas that should be used for the Safe transaction.
_10const safeTransaction = await protocolKit.createTransaction(_10 '0x...',_10 options: {_10 safeTxGas: '123'_10 }_10)
options.baseGas
(Optional)
- Type:
string
The gas costs for the data used to trigger the Safe transaction.
_10const safeTransaction = await protocolKit.createTransaction(_10 '0x...',_10 options: {_10 baseGas: '123'_10 }_10)
options.gasPrice
(Optional)
- Type:
string
The price in wei that the sender is willing to pay for each unit of gas.
_10const safeTransaction = await protocolKit.createTransaction(_10 '0x...',_10 options: {_10 gasPrice: '123'_10 }_10)
options.gasToken
(Optional)
- Type:
string
The token address that is used for the gas payment, or 0x0000000000000000000000000000000000000000
if there is no payment.
_10const safeTransaction = await protocolKit.createTransaction(_10 '0x...',_10 options: {_10 gasToken: '0x...'_10 }_10)
options.refundReceiver
(Optional)
- Type:
string
The address of the gas payment receiver or 0x0000000000000000000000000000000000000000
if there is no payment.
_10const safeTransaction = await protocolKit.createTransaction(_10 '0x...',_10 options: {_10 refundReceiver: '0x...'_10 }_10)
options.nonce
(Optional)
- Type:
number
The transaction nonce.
_10const safeTransaction = await protocolKit.createTransaction(_10 '0x...',_10 options: {_10 nonce: 123_10 }_10)
Returns
Promise<SafeTransaction>
The Safe transaction object ready to be signed.