> For the complete documentation index, see [llms.txt](https://docs.citrea.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.citrea.xyz/developer-documentation/run-a-node/bitcoin-mainnet/mainnet-source.md).

# Build Bitcoin Core from Source

### Step 1: Clone the Bitcoin Core repository

Clone the repository from the official Bitcoin Core repository:

```sh
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
git checkout v30.2
```

### Step 2: Build Bitcoin Core

Follow the instructions to build the repository for [Linux](https://github.com/bitcoin/bitcoin/blob/v30.2/doc/build-unix.md), [macOS](https://github.com/bitcoin/bitcoin/blob/v30.2/doc/build-osx.md), or [Windows](https://github.com/bitcoin/bitcoin/blob/v30.2/doc/build-windows.md). You don't need to reclone the repo if you're asked to, since we've already done that.

### Step 3: Run Mainnet Node

After building, you can run the following:

```sh
bitcoind -daemon -txindex=1 -rpcbind=0.0.0.0 -rpcport=8332 -rpcuser=citrea -rpcpassword=citrea
```

The arguments you provide here are important - if you modify any of these, you may also need to modify some fields before running a Citrea client in the next steps. Please check everything carefully before proceeding.

{% hint style="info" %}
**Testnet4 setup:** To run a Bitcoin Testnet4 node for Citrea's testnet, add the `-testnet4` flag and use the testnet4 RPC port `18443`:

```sh
bitcoind -testnet4 -daemon -txindex=1 -rpcbind=0.0.0.0 -rpcport=18443 -rpcuser=citrea -rpcpassword=citrea
```

{% endhint %}
