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

# sendRawTransaction

# sendRawTransaction

Sends a raw Bitcoin transaction using the mempool.space API. This is useful when you have a fully constructed and signed raw transaction that you want to broadcast to the network.

## Usage

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

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isBitcoinWalletAccount(walletAccount)) {
  const { transactionId } = await sendRawTransaction({
    walletAccount,
    rawTransaction: "0100000001...", // Hex-encoded raw transaction
  });

  console.log("Transaction broadcast:", transactionId);
}
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `rawTransaction` | `string` | The raw transaction in hexadecimal format |
| `walletAccount` | `BitcoinWalletAccount` | The wallet account (used to determine network) |
| `client` | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple clients. |

## Returns

`Promise<{ transactionId: string }>` - A promise that resolves to an object containing the transaction ID.

## Errors

| Error | Description |
| - | - |
| `SendBitcoinRawTransactionError` | Thrown if the transaction broadcast fails |

## React

```tsx theme={"system"}
import { sendRawTransaction, isBitcoinWalletAccount } from '@dynamic-labs-sdk/bitcoin';
import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
import { useState } from 'react';

function BroadcastButton({ rawTransaction }) {
  const { data: walletAccounts = [] } = useGetWalletAccounts();
  const walletAccount = walletAccounts.find(isBitcoinWalletAccount);
  const [txId, setTxId] = useState('');

  const handleBroadcast = async () => {
    if (!walletAccount) return;
    const { transactionId } = await sendRawTransaction({ walletAccount, rawTransaction });
    setTxId(transactionId);
  };

  return (
    <div>
      <button onClick={handleBroadcast} disabled={!walletAccount}>Broadcast</button>
      {txId && <p>Transaction ID: {txId}</p>}
    </div>
  );
}
```

## Related functions

* [sendBitcoin](https://docs.dynamic.xyz/docs/javascript/reference/bitcoin/send-bitcoin.md) - Send a simple Bitcoin transaction
* [signPsbt](https://docs.dynamic.xyz/docs/javascript/reference/bitcoin/sign-psbt.md) - Sign a PSBT


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