Skip to main content

Set up Bitcoin and Ethereum nodes

This tutorial helps you set up a Bitcoin testnet and Ethereum Ropsten testnet node on your local machine using Bitcoin Core and Geth. In particular, this is useful for completing Exercise 3 when you do not have existing testnet nodes, or as a reference for how to configure your nodes running on a different setup.

Bitcoin testnet node#

Set up a Bitcoin testnet node using bitcoind from Bitcoin Core.

  1. Download Bitcoin Core.

Find the installation guide for your machine from the Github Repo. Follow the instructions to download the binary executable commands, including bitcoind. Do not use the bitcoind command to start downloading the blockchain until later.

  1. Find the directory where the bitcoind command executable is located. This is typically in the cloned bitcoin repo, under the src folder. cd into the directory so you can use the bitcoind command.

  2. Check that bitcoind is installed properly

./bitcoind --help
  1. Find the default data directory of your Bitcoin node. Create a file called bitcoin.conf inside this directory.

eg) For macOS

mkdir -p "/Users/jacky/Library/Application Support/Bitcoin"touch "/Users/jacky/Library/Application Support/Bitcoin/bitcoin.conf"chmod 600 "/Users/jacky/Library/Application Support/Bitcoin/bitcoin.conf"

Use the above commands and change the folder path to be the data directory of your system.

  1. Generate the Bitcoin node configuration file used by bitcoind.

Use this tool to create the contents of your bitcoin.conf file. Note: The following settings are general guidelines that work for most setups. Your setup may require some changes.

Set the following:

  • At the top, set your operating system.
  • Under Bitcoin Core, enable Daemon Mode.
  • Under RPC API, enable RPC Server.
  • Under RPC API, look for RPC Auth. Follow the link and provide a username and password. Write down the username and password as you will need it later. Copy the generated value and paste it back into the RPC Auth field.
  • Under RPC API, set RPC Allow IP Address as 0.0.0.0/0.
  • Under RPC API, set Bind RPC Address as the public IP address of the bitcoin node.

Copy the contents of the generated bitcoin.conf file and paste it into the file you created in the last step.

Under # Options only for testnet [test] add the following two lines, then save.

# Listen for JSON-RPC connections on this portrpcport=8332
  1. Start downloading the bitcoin testnet chain. Go back to the directory where the bitcoind binary is located to run the following.
./bitcoind -testnet

You should see a message Bitcoin Core starting. Wait for the Bitcoin testnet chain to download, this could take a few hours. If you want to look at the progress, find the debug.log file within the default Bitcoin data directory.

eg) For macOS, you can run

tail -10 ~/Library/Application\ Support/Bitcoin/testnet3/debug.log

To stop the Bitcoin testnet node from downloading and syncing

./bitcoin-cli -testnet stop
  1. Find the RPC endpoint for Axelar to connect.

If you used the above settings, your RPC endpoint should be

http://{USERNAME}:{PASSWORD}@host.docker.internal:8332

eg)

http://jacky:mypassword@host.docker.internal:8332

The username and password fields are the values you provided to the RPC Auth setting in step 5. Write down the Bitcoin RPC endpoint as you will need it later.

  1. OPTIONAL: Test your Bitcoin node.

After your Bitcoin node is fully synced, you can send an RPC request to it using cURL. Use the following and replace the RPC endpoint username and password.

curl -X POST http://jacky:mypassword@localhost:8332 \-H "Content-Type: application/json" \--data '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}'

Ethereum Ropsten testnet node#

Set up an Ethereum Ropsten testnet node using Geth.

  1. Install Geth.

  2. Start downloading the Ethereum Ropsten testnet chain. This may take many hours.

geth --ropsten --syncmode "snap" --http --http.vhosts "*"

First, the majority of the blocks will be downloaded. Then your node will synchronize as the last few blocks catch up. This second part may take a long time.

To stop the node from downloading, press Control C.

  1. Check the status of your node.

First find the path to your node's ipc which is located in

{Path to Default Ethereum Data Storage}/ropsten/geth.ipc

eg) on macOS

/Users/jacky/Library/Ethereum/ropsten/geth.ipc

Open a new terminal and run the following. Replace the ipc path with your own.

geth attach ipc:/Users/jacky/Library/Ethereum/ropsten/geth.ipc

Check the status of your Ethereum node.

eth.syncing
  1. Find the RPC endpoint for Axelar to connect.

If you used the above settings, your RPC endpoint should be

http://host.docker.internal:8545

Write down the RPC endpoint, you will need it later.

  1. OPTIONAL: Test your Ethereum node.

After your Ethereum node is fully synced, you can send an RPC request to it using cURL.

curl -X POST http://localhost:8545 \-H "Content-Type: application/json" \--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'