How to build your own testnet and test the smt hardfork yourself


In the past weeks, there was a lot of times where the official testnet was down because the steemit team didn't want to put it back up until they fixed the issue that made it crash. Which is understandeable, but it slows down testing by quite a bit, same goes for getting actual testnet funds. Usually the testnet goes up and then we have to wait a few additionnal days to get funds to do actual testing.

So I decided to build my own local testnet for those reasons, first to stop breaking the public testnet whenever I find something bad and second to test my own fixes. Like the one :

How to setup a local testnet and test things on it

I do my testing on ubuntu 19, but it's better to have ubuntu 18 as I'm forced to do some hacks to get it working.

You need about 10gb of disk space, 8gb of ram and the faster/more core your cpu has, the better.

If you are reading this in the future (in months/years), this doc may be more up to date :

So first of all install all of the dependencies :

# Required packages
sudo apt-get install -y \
    autoconf \
    automake \
    cmake \
    g++ \
    git \
    libbz2-dev \
    libsnappy-dev \
    libssl-dev \
    libtool \
    make \
    pkg-config \
    python3 \
    python3-jinja2 \

# Boost packages (also required)
sudo apt-get install -y \
    libboost-chrono-dev \
    libboost-context-dev \
    libboost-coroutine-dev \
    libboost-date-time-dev \
    libboost-filesystem-dev \
    libboost-iostreams-dev \
    libboost-locale-dev \
    libboost-program-options-dev \
    libboost-serialization-dev \
    libboost-signals-dev \
    libboost-system-dev \
    libboost-test-dev \

# Optional packages (not required, but will make a nicer experience)
sudo apt-get install -y \
    libncurses5-dev \
    libreadline-dev \

Get and build steem

In this step we are checking out the master branch, but it may not be the correct branch to do testing, for instance the current "valid" branch for testing is 20200205-check-emission-accounts if you don't know which one it is, ask around :)

git clone
cd steem
git checkout stable
git submodule update --init --recursive
mkdir build
cd build

Then we call cmake to configure our build options to build a testnet instead of a main net


And finally you can build steemd

make -j$(nproc) steemd

Some notes on make -j$(nproc) when I build with all of my cores, my computer tends to freeze and crash, so I would suggest trying out like this and then if you experience some bad freezes to reduce the number of core used.

You can also build the cli wallet and the unit test util but that's optional:

make -j$(nproc) cli_wallet chain_test

Now you should be good to go to run and configure your testnet.

Configuring and running your testnet

Run for a few seconds and then exit steemd like so ./programs/steemd/steemd -d testnet/

You will see something like this



initminer public key: TST6LLegbAgLAy28EHrffBVuANFWcFgmqRMW13wBmTExqFE9SCkg4
initminer private key: 5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n
blockchain version: 0.23.0

Save initminer's private key somewhere.

Now, after running steemd, you should now have a testnet directory and in it what's interesting to us is the config.ini.

You want to edit it and change these fields :

# Enable block production, even if the chain is stale.
enable-stale-production = 1

# Percent of witnesses (0-99) that must be participating in order to produce blocks
required-participation = 0

# name of witness controlled by this node (e.g. initwitness )
witness = "initminer"

# WIF PRIVATE KEY to be used by one or more witnesses or miners
private-key = 5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n

# Skip enforcing bandwidth restrictions. Default is true in favor of rc_plugin.
witness-skip-enforce-bandwidth = 1

# Local http endpoint for webserver requests.
webserver-http-endpoint =

# Local websocket endpoint for webserver requests.
webserver-ws-endpoint =

plugin = webserver p2p json_rpc witness account_by_key reputation market_history

plugin = database_api account_by_key_api network_broadcast_api reputation_api market_history_api condenser_api block_api rc_api

And you're good to go, you should now have a full testnet node. Run steemd again and you should see something like this:


Congrats ! Your testnet is running :)

Actually using your testnet

Now go up a bit in the logs to find the chain_id, it should be the very first thing you see :

$ ./programs/steemd/steemd -d testnet
1808419ms database.cpp:522              set_chain_id         ] steem_chain_id: 18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e 
1808419ms rc_plugin.cpp:1466            plugin_initialize    ] Initializing resource credit plugin
1808424ms rc_plugin.cpp:1557            plugin_initialize    ] RC's will be computed starting at block 1

As you noticed we configured above the http endpoint to be Well now you can use your favorite library to interact with your local node.

Here's a small code snippet using steem-js, note how I use my custom chain id and url:

var steem = require('steem');
steem.api.setOptions({url: '', useAppbaseApi :  true, address_prefix : 'TST', 'chain_id' : '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e'});

steem.api.getAccounts(['initminer'], function(err, response){
    console.log(err, response);

You can also use the cli wallet to interact with it using the wss endpoint.

Now that you are running things locally you can just make changes to the code, recompile and re-run the testnet to check your changes :)

And if you feel that you have messed up a bit too much, just go to your testnet folder and erase the content of the blockchain folder.

Final thoughts and additionnal material

You may want to test things on a testnet that is more akin to the main net (with all the data in it) and for that I recommend using tinman and gatling from @inertia
And it's guide :

3 columns
2 columns
1 column