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

# Bitcoin quickstart

> Stream Bitcoin Taproot outputs with Pipes SDK.

Pipes SDK streams typed Bitcoin blocks, transactions, inputs, and outputs from SQD Portal. This bounded example reads Taproot outputs from block 880,000 and joins them to their transactions.

<Note>
  The Pipes CLI currently scaffolds EVM and SVM projects only. Set up Bitcoin pipes manually as shown here.
</Note>

## Prerequisites

* Node.js 22.15 or later
* npm, pnpm, or yarn

## Create the project

```bash theme={"system"}
mkdir bitcoin-pipe && cd bitcoin-pipe
npm init -y
npm pkg set type=module
npm install @subsquid/pipes@beta tsx
```

Create `index.ts`:

```ts theme={"system"}
import { bitcoinPortalStream, bitcoinQuery } from '@subsquid/pipes/bitcoin'

const stream = bitcoinPortalStream({
  id: 'bitcoin-taproot-outputs',
  portal: 'https://portal.sqd.dev/datasets/bitcoin-mainnet',
  outputs: bitcoinQuery()
    .addFields({
      block: { number: true, timestamp: true },
      transaction: { transactionIndex: true, txid: true },
      output: {
        transactionIndex: true,
        outputIndex: true,
        value: true,
        scriptPubKeyAddress: true,
      },
    })
    .addOutputRequest({
      range: { from: 880_000, to: 880_000 },
      request: {
        scriptPubKeyType: ['witness_v1_taproot'],
        transaction: true,
      },
    }),
})

for await (const { data } of stream) {
  for (const block of data) {
    const transactions = new Map(
      block.transactions.map((tx) => [tx.transactionIndex, tx]),
    )

    for (const output of block.outputs) {
      console.log({
        block: block.header.number,
        txid: transactions.get(output.transactionIndex)?.txid,
        outputIndex: output.outputIndex,
        address: output.scriptPubKeyAddress,
        valueBtc: output.value,
      })
    }
  }
}
```

Run it:

```bash theme={"system"}
npx tsx index.ts
```

Output values are BTC numbers, not satoshis. Bitcoin hashes and scripts are bare hex without a `0x` prefix, and block timestamps are Unix seconds.

## Next steps

* [Handle Bitcoin data](./guides/basic-development/handling-bitcoin-data) for UTXO joins, values, and identifiers.
* [Query builder reference](./reference/basic-components/query-builder) for every field and filter.
* [Bitcoin portal stream](./reference/basic-components/source#rpc-latency-watcher) for monitoring Portal freshness against Bitcoin RPC nodes.
* Use the shared [Postgres](../evm/reference/basic-components/target/postgres-drizzle), [ClickHouse](../evm/reference/basic-components/target/clickhouse), [BigQuery](../evm/reference/basic-components/target/bigquery), or [Parquet](../evm/reference/basic-components/target/parquet) target APIs to persist the stream.


## Related topics

- [Bitcoin](/en/data/bitcoin/bitcoin-mainnet.md)
- [Solana Portal Quickstart](/en/portal/solana/quickstart.md)
- [EVM Portal Quickstart](/en/portal/evm/quickstart.md)
- [Pipes SDK 1.0](/announcements/pipes-sdk-1-0.md)
- [Quickstart](/en/sdk/squid-sdk/starknet/quickstart.md)
