Learn how to sync a Bitcoin node for building Bitcoin applications.
Syncing a Bitcoin node is often one of the first steps a developer takes when building a Bitcoin application. It's a great introduction to the Bitcoin developer ecosystem, and if you're relying on on-chain data, there's no safer way to get that data than doing it yourself.
In this guide, you will learn how to:
1Download Bitcoin Core daemon on your machine
2Configure bitcoind
3Start syncing your node
4Properly shutdown and restart your node
Requirements
To get started, we first need to download bitcoind. In our example, we'll be using version 25.0. You can select a software version compatible with your device from this list.
Configure bitcoind
Once your download is complete, make note of your path to the bitcoind executable.
Note
When you sync your node, we'll be running the program at /bitcoin-25.0/bin/bitcoin, which is where the bitcoind executable is located.
Next up is a couple configuration steps.
1Select or create a directory to store your Bitcoin data.
2Update the bitcoin.conf file to include the path to your Bitcoin data directory.
The Bitcoin chainstate is pretty large, and you need a place to store it. In this example, we are going to set up a directory called bitcoin-data on an external hard drive that we have mounted at /Volumes/SSD.
Note
This folder, bitcoin-data, can be named whatever you like, and can exist locally or in an external hard drive.
The most important thing is that it should exist in a place that has enough storage to hold all the Bitcoin data we will be receiving once it starts to sync.
Now navigate to your bitcoin.conf file, which is located in your /path/to/bitcoin directory and update the datadir field with your directory.
In this example, it would look like this:
bitcoin.conf
datadir=/Volumes/SSD/bitcoin-data/
If you plan to use your node to receive transactions, you will need to make note of the username and password fields for your node.
Note
In the example bitcoin.conf above, devnet is listed as the default username and password.
After running this command, you will see zmq_url entries in your console's stdout, displaying ZeroMQ logs from your Bitcoin node. Congrats! You're now syncing!
Note
It might take anywhere from a few hours to a few days to run and fully sync, depending on if it's your first time syncing a node.