> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# signPsbts

# signPsbts

Signs multiple Partially Signed Bitcoin Transactions (PSBTs) in a single operation. This is useful for batch operations or when working with multiple transactions that need to be signed together.

> [!NOTE]
>
> Each request follows the same rules as signing a single PSBT. With an embedded wallet, that includes the address and option constraints described in [Embedded Wallet Differences](https://docs.dynamic.xyz/docs/javascript/reference/bitcoin/embedded-wallet-differences.md).

## Usage

```javascript theme={"system"}
import { signPsbts, isBitcoinWalletAccount } from "@dynamic-labs-sdk/bitcoin";
import { getPrimaryWalletAccount } from "@dynamic-labs-sdk/client";

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isBitcoinWalletAccount(walletAccount)) {
  const { signedPsbts } = await signPsbts({
    walletAccount,
    requests: [
      {
        unsignedPsbtBase64: "cHNidP8BAH...",
        allowedSighash: [1],
        signature: [
          {
            address: walletAccount.address,
            signingIndexes: [0],
          },
        ],
      },
      {
        unsignedPsbtBase64: "cHNidP8BAI...",
        allowedSighash: [1],
        signature: [
          {
            address: walletAccount.address,
            signingIndexes: [0, 1],
          },
        ],
      },
    ],
  });

  console.log("Signed PSBTs:", signedPsbts);
}
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `requests` | `BitcoinSignPsbtRequest[]` | Array of PSBT signing requests |
| `requests[].unsignedPsbtBase64` | `string` | The unsigned PSBT encoded in Base64 |
| `requests[].allowedSighash` | `number[]` | Array of allowed signature hash types |
| `requests[].allowedWitnessScripts` | `string[]` (optional) | Embedded wallets only. Hex-encoded witness scripts of P2WSH multisig inputs the wallet may co-sign. Ignored by external wallets. |
| `requests[].signature` | `Array` (optional) | Array of signature configuration objects |
| `walletAccount` | `BitcoinWalletAccount` | The wallet account to sign with |
| `client` | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple clients. |

## Returns

`Promise<{ signedPsbts: string[] }>` - A promise that resolves to an object containing an array of signed PSBTs in Base64 format.

## Errors

| Error | Description |
| - | - |
| `NotBitcoinProviderError` | Thrown if the wallet account's provider is not a Bitcoin provider |

## Related functions

* [signPsbt](https://docs.dynamic.xyz/docs/javascript/reference/bitcoin/sign-psbt.md) - Sign a single PSBT
* [sendBitcoin](https://docs.dynamic.xyz/docs/javascript/reference/bitcoin/send-bitcoin.md) - Send a simple Bitcoin transaction
* [Embedded Wallet Differences](https://docs.dynamic.xyz/docs/javascript/reference/bitcoin/embedded-wallet-differences.md) - How these options behave with embedded wallets


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.