# Creating a Bitcoin Transaction

For usage with the `clarity-bitcoin-lib` contract or if you just want to learn how to invoke a bitcoin transaction from your wallet on the front end, check out this guide.

Using Stacks Connect and with a Stacks-supported wallet, you can initiate a simple Bitcoin transaction from a frontend app in a few lines of code. With this Bitcoin transaction, you can then use it to verify its inclusion in a Bitcoin block through Clarity.

{% hint style="info" %}
Check out the [Stacks Connect](/stacks-connect/connect-wallet.md) guides for more info on setup and wallet connection.
{% endhint %}

{% stepper %}
{% step %}

#### Initiate a Bitcoin transaction

Use the `request("sendTransfer", ...)` method to initiate a bitcoin transaction. Provide the recipient address and the amount in satoshis.

```typescript
import { request } from '@stacks/connect';

const result = await request('sendTransfer', {
    recipients: [
      {
        address: "<recipient-address>",
        amount: 100_000,
      },
    ],
  })

let txid = result.txid;
```

{% endstep %}

{% step %}

#### Cache the \`txid\`

As you'll see in the next section, in order to verify a transaction was mined in Clarity, you'll use the returned `txid` to fetch its transaction metadata. The transaction metadata can be fetched from a Bitcoin explorer or from some custom helper libraries built by the community. So it's important to cache or store the `txid` for your app.
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stacks.co/more-guides/verify-bitcoin-transactions-clarity/creating-btc-tx.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
