# `createSwapOwnerTx`

Returns a Safe transaction to replace an owner of the connected Safe with a new one.

## Usage

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

    const params: SwapOwnerTxParams = {
      oldOwnerAddress,
      newOwnerAddress
    }

    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.createSwapOwnerTx(
      params,
      options // Optional
    )
    ```
  </Tabs.Tab>
  <Tabs.Tab>
    ```typescript
    import {
      SwapOwnerTxParams,
      PasskeyArgType,
      SafeTransactionOptionalProps
    } from '@safe-global/protocol-kit'
    import { protocolKit } from './setup.ts'

    const newOwnerPasskey: PasskeyArgType = {
      rawId,
      coordinates
    }

    const params: SwapOwnerTxParams = {
      oldOwnerAddress,
      newOwnerPasskey
    }

    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.createSwapOwnerTx(
      params,
      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

### `params.oldOwnerAddress`

- **Type**: `string`

The address of the owner to remove to the Safe.

```typescript focus=2
const safeTransaction = await protocolKit.createSwapOwnerTx({
  oldOwnerAddress: '0x...',
  newOwnerAddress: '0x...'
})
```

### `params.newOwnerAddress` (Optional)

- **Type**: `string`

The address of the owner to add to the Safe.

```typescript focus=3
const safeTransaction = await protocolKit.createSwapOwnerTx({
  oldOwnerAddress: '0x...',
  newOwnerAddress: '0x...'
})
```

### `params.newOwnerPasskey`

- **Type**: `PasskeyArgType`

The passkey associated with the owner to add to the Safe.

```typescript focus=3
const safeTransaction = await protocolKit.createSwapOwnerTx({
  oldOwnerAddress: '0x...',
  newOwnerPasskey
})
```

### `options.safeTxGas` (Optional)

- **Type**: `string`

The gas that should be used for the Safe transaction.

```typescript focus=7
const safeTransaction = await protocolKit.createSwapOwnerTx(
  {
    oldOwnerAddress: '0x...',
    newOwnerAddress: '0x...'
  },
  {
    safeTxGas: '123'
  }
)
```

### `options.baseGas` (Optional)

- **Type**: `string`

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

```typescript focus=7
const safeTransaction = await protocolKit.createSwapOwnerTx(
  {
    oldOwnerAddress: '0x...',
    newOwnerAddress: '0x...'
  },
  {
    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=7
const safeTransaction = await protocolKit.createSwapOwnerTx(
  {
    oldOwnerAddress: '0x...',
    newOwnerAddress: '0x...'
  },
  {
    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=7
const safeTransaction = await protocolKit.createSwapOwnerTx(
  {
    oldOwnerAddress: '0x...',
    newOwnerAddress: '0x...'
  },
  {
    gasToken: '0x...'
  }
)
```

### `options.refundReceiver` (Optional)

- **Type**: `string`

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

```typescript focus=7
const safeTransaction = await protocolKit.createSwapOwnerTx(
  {
    oldOwnerAddress: '0x...',
    newOwnerAddress: '0x...'
  },
  {
    refundReceiver: '0x...'
  }
)
```

### `options.nonce` (Optional)

- **Type**: `number`

The transaction nonce.

```typescript focus=7
const safeTransaction = await protocolKit.createSwapOwnerTx(
  {
    oldOwnerAddress: '0x...',
    newOwnerAddress: '0x...'
  },
  {
    nonce: 123
  }
)
```

## Returns

`Promise<SafeTransaction>`

The Safe transaction to replace an owner.
