> **Key takeaway:**  ☞   The renaming of "Ledger Live" to "Ledger Wallet" and\
>      "wallet" (in the hardware sense) to "signer" is still in progress.\
>      This page may contain legacy references that will be updated.

# Using the Transaction Module in Wallet API Core Client

The Transaction Module allows you to interact with user transactions. It enables you to let the user sign a transaction and also allows you to sign and broadcast a transaction through .

## Transaction Module Overview

Access the Transaction module via `walletApiClient.transaction`.

### Methods:

#### 1. Sign Transaction

Let the user sign a transaction without broadcasting it. This is useful if you want to sign a transaction for later use.

```javascript
walletApiClient.transaction.sign(
    accountId: string,
    transaction: Transaction,
    options?: TransactionSign["params"]["options"],
    meta?: Record<string, unknown>
): Promise<Buffer>
```

**Parameters**:

- `accountId` (required): The ID of the account where the transaction will be made.
- `transaction` (required): The [transaction object](../../appendix/transaction) in the currency family-specific format.
- `options` (optional): Extra parameters that might be needed for the transaction. See [references](../../appendix/transaction#transactionsign-type) for more information.
- `meta` (optional): Metadata for the transaction.

**Returns**: A promise that resolves with the raw signed transaction as a Buffer.

[**Required permission**:](https://developers.ledger.com/docs/ledger-live/discover/guides/wallet-api/appendix/manifest#permissions)
`transaction.sign`

##### Example:

```javascript
async function signTransaction(
  walletApiClient,
  accountId,
  transaction,
  options,
  meta
) {
  try {
    const signedTransaction = await walletApiClient.transaction.sign(
      accountId,
      transaction,
      options,
      meta
    );
    console.log("Signed transaction:", signedTransaction);
  } catch (error) {
    console.error("Error signing transaction:", error);
  }
}
```

#### 2. Sign and Broadcast Transaction

Let the user sign a transaction and broadcast it to the network.

```javascript
walletApiClient.transaction.signAndBroadcast(
    accountId: string,
    transaction: Transaction,
    options?: TransactionSignAndBroadcast["params"]["options"],
    meta?: Record<string, unknown>
): Promise<string>
```

**Parameters**:

- `accountId` (required): The ID of the account where the transaction will be made.
- `transaction` (required): The [transaction object](../../appendix/transaction) in the currency family-specific format.
- `options` (optional): Extra parameters that might be needed for the transaction. See [references](../../appendix/transaction#transactionsignandbroadcast-type) for more information.
- `meta` (optional): Metadata for the transaction.

**Returns**: A promise that resolves with the transaction hash as a string.

[**Required permission**:](https://developers.ledger.com/docs/ledger-live/discover/guides/wallet-api/appendix/manifest#permissions)
`transaction.signAndBroadcast`

##### Example:

```javascript
async function signAndBroadcastTransaction(
  walletApiClient,
  accountId,
  transaction,
  options,
  meta
) {
  try {
    const transactionHash = await walletApiClient.transaction.signAndBroadcast(
      accountId,
      transaction,
      options,
      meta
    );
    console.log("Transaction Hash:", transactionHash);
  } catch (error) {
    console.error("Error signing and broadcasting transaction:", error);
  }
}
```

## Handling Errors

Make sure to handle errors gracefully and provide appropriate feedback to the user. Additionally, always remember to disconnect the `WindowMessageTransport` when you're done interacting with the  API to free up resources.
