# `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


<Tabs items={['example.ts', 'setup.ts']}>
  <Tabs.Tab>
    ```typescript
    import { SafeTransactionOptionalProps } from '@safe-global/protocol-kit'
    import { MetaTransactionData, OperationType } from '@safe-global/types-kit'
    import { protocolKit } from './setup.ts'

    const transactions: MetaTransactionData[] = [{
      to: '0x...',
      value: '123',
      data: '0x',
      operation: OperationType.Call // Optional
    }]

    const options: SafeTransactionOptionalProps = {
      safeTxGas: '123', // Optional
      baseGas: '123', // Optional
      gasPrice: '123', // Optional
      gasToken: '0x...', // Optional
      refundReceiver: '0x...', // Optional
      nonce: 123 // Optional
    }

    const safeTransaction = await protocolKit.createTransaction({
      transactions,
      onlyCalls: true, // Optional
      options // Optional
    })
    ```
  </Tabs.Tab>
  <Tabs.Tab>
    ```typescript
    import Safe from '@safe-global/protocol-kit'

    export const protocolKit = Safe.init({
      provider,
      signer,
      safeAddress: '0x...'
    })
    ```
  </Tabs.Tab>
</Tabs>


## Parameters

### `transactions.to`

- **Type:** `string`

The address of the recipient.

```typescript focus=3
const safeTransaction = await protocolKit.createTransaction({
  transactions: [{
    to: '0x...',
    value: '123',
    data: '0x'
  }]
})
```

### `transactions.value`

- **Type:** `string`

The amount of native tokens that are transferred.

```typescript focus=4
const safeTransaction = await protocolKit.createTransaction({
  transactions: [{
    to: '0x...',
    value: '123',
    data: '0x'
  }]
})
```

### `transactions.data`

- **Type:** `string`

The encoded transaction data.

```typescript focus=5
const safeTransaction = await protocolKit.createTransaction({
  transactions: [{
    to: '0x...',
    value: '123',
    data: '0x'
  }]
})
```

### `transactions.operation` (Optional)

- **Type:** `OperationType`
- **Default:** `0`

The operation of the Safe transaction. `0` for a *Call* and `1` for a *DelegateCall*.

```typescript focus=6
const safeTransaction = await protocolKit.createTransaction({
  transactions: [{
    to: '0x...',
    value: '123',
    data: '0x',
    operation: 0
  }]
})
```

### `onlyCalls` (Optional)

- **Type**: `boolean`
- **Default**: `false`

A boolean variable that forces the use of the [`MultiSendCallOnly`](https://github.com/safe-global/safe-smart-account/blob/main/contracts/libraries/MultiSendCallOnly.sol) contract instead of the [`MultiSend`](https://github.com/safe-global/safe-smart-account/blob/main/contracts/libraries/MultiSend.sol) when sending a batch transaction.

```typescript focus=3
const safeTransaction = await protocolKit.createTransaction(
  '0x...',
  onlyCalls: true
)
```

### `options.safeTxGas` (Optional)

- **Type**: `string`

The gas that should be used for the Safe transaction.

```typescript focus=4
const safeTransaction = await protocolKit.createTransaction(
  '0x...',
  options: {
    safeTxGas: '123'
  }
)
```

### `options.baseGas` (Optional)

- **Type**: `string`

The gas costs for the data used to trigger the Safe transaction.

```typescript focus=4
const safeTransaction = await protocolKit.createTransaction(
  '0x...',
  options: {
    baseGas: '123'
  }
)
```

### `options.gasPrice` (Optional)

- **Type**: `string`

The price in wei that the sender is willing to pay for each unit of gas.

```typescript focus=4
const safeTransaction = await protocolKit.createTransaction(
  '0x...',
  options: {
    gasPrice: '123'
  }
)
```

### `options.gasToken` (Optional)

- **Type**: `string`

The token address that is used for the gas payment, or `0x0000000000000000000000000000000000000000` if there is no payment.

```typescript focus=4
const safeTransaction = await protocolKit.createTransaction(
  '0x...',
  options: {
    gasToken: '0x...'
  }
)
```

### `options.refundReceiver` (Optional)

- **Type**: `string`

The address of the gas payment receiver or `0x0000000000000000000000000000000000000000` if there is no payment.

```typescript focus=4
const safeTransaction = await protocolKit.createTransaction(
  '0x...',
  options: {
    refundReceiver: '0x...'
  }
)
```

### `options.nonce` (Optional)

- **Type**: `number`

The transaction nonce.

```typescript focus=4
const safeTransaction = await protocolKit.createTransaction(
  '0x...',
  options: {
    nonce: 123
  }
)
```

## Returns

`Promise<SafeTransaction>`

The Safe transaction object ready to be signed.
