BitSong
Search…
Join the Mainnet
Make sure to have the latest go-bitsong version installed. First, initialize the node.
1
bitsongd init <your_custom_moniker>
Copied!
Note Monikers can contain only ASCII characters. Using Unicode characters is not supported and renders your node unreachable.
By default, the init command creates your ~/.bitsongd directory with subfolders config and data. In the config directory, the most important files for configuration are app.toml and config.toml.
You can edit the moniker in the ~/.bitsongd/config/config.toml file:
1
# A custom human readable name for this node
2
moniker = "<your_custom_moniker>"
Copied!
For optimized node performance, edit the ~/.bitsongd/config/app.toml file to enable the anti-spam mechanism and reject incoming transactions with less than the minimum gas prices:
1
# This is a TOML config file.
2
# For more information, see https://github.com/toml-lang/toml
3
4
###############################################################################
5
### Base Configuration ###
6
###############################################################################
7
8
# The minimum gas prices a validator is willing to accept for processing a
9
# transaction. A transaction's fees must meet the minimum of any denomination
10
# specified in this config (e.g. 0.25token1;0.0001token2).
11
12
minimum-gas-prices = "0.0025ubtsg"
Copied!
Your full node has been initialized!

Genesis & Seeds

Copy the Genesis File

Fetch the mainnet's genesis.json file into bitsongd's config directory.
1
wget -O ~/.bitsongd/config/genesis.json https://raw.githubusercontent.com/bitsongofficial/networks/master/bitsong-2b/genesis.json
Copied!

Set persistent peers

Your node needs to know how to find peers. You'll need to add healthy seed nodes to $HOME/.bitsongd/config/config.toml
2
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" ~/.bitsongd/config/config.toml
Copied!

Synchronise the Node

Now we have to syncronise the node with the current state of the blockchain. The fastest way to achieve this is by using state sync, which we will use for this purpose.
1
# Thanks to qf3l3k for creating and testing these commands
2
3
sudo systemctl stop bitsong && bitsongd unsafe-reset-all
4
5
SNAP_RPC="https://rpc.bitsong.forbole.com:443"
6
SNAP_RPC2="https://bitsong.stakesystems.io:2053"
7
8
LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \
9
BLOCK_HEIGHT=$((LATEST_HEIGHT - 1000)); \
10
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
11
13
14
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" $HOME/.bitsongd/config/config.toml
15
16
sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
17
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC2\"| ; \
18
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
19
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"| ; \
20
s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" $HOME/.bitsongd/config/config.toml
21
22
sudo systemctl restart bitsong
23
24
sudo journalctl -u bitsong -f
Copied!

Enable the REST API

By default, the REST API is disabled. To enable the REST API, edit the ~/.bitsongd/config/app.toml file, and set enable to true in the [api] section.
1
###############################################################################
2
### API Configuration ###
3
###############################################################################
4
5
[api]
6
7
# Enable defines if the API server should be enabled.
8
enable = false
9
10
# Swagger defines if swagger documentation should automatically be registered.
11
swagger = false
12
13
# Address defines the API server to listen on.
14
address = "tcp://0.0.0.0:1317"
Copied!
Optionally, you can activate swagger by setting swagger to true or change the port of the REST API in the parameter address. After restarting your application, you can access the REST API on YOURNODEIP:1317.

GRPC Configuration

By default, gRPC is enabled on port 9090. In the ~/.bitsongd/config/app.toml file, you can make changes in the gRPC section. To disable the gRPC endpoint, set enable to false. To change the port, use the address parameter.
1
###############################################################################
2
### gRPC Configuration ###
3
###############################################################################
4
5
[grpc]
6
7
# Enable defines if the gRPC server should be enabled.
8
enable = true
9
10
# Address defines the gRPC server address to bind to.
11
address = "0.0.0.0:9090"
Copied!

Background Process

To run the node in a background process with automatic restarts, you can use a service manager like systemd. To set this up run the following:
1
sudo tee /etc/systemd/system/bitsongd.service > /dev/null <<EOF
2
[Unit]
3
Description=BitSong Network Daemon
4
After=network-online.target
5
6
[Service]
7
User=$USER
8
ExecStart=$(which bitsongd) start
9
Restart=always
10
RestartSec=3
11
LimitNOFILE=4096
12
13
[Install]
14
WantedBy=multi-user.target
15
EOF
Copied!
Then setup the daemon
1
sudo -S systemctl daemon-reload
2
sudo -S systemctl enable bitsongd
Copied!
We can then start the process and confirm that it is running
1
sudo -S systemctl start bitsongd
2
3
sudo service bitsongd status
Copied!