본문으로 건너뛰기

Compile from Sources

You can download prebuilt binaries here.

If you still want to compile sources yourself, follow the instructions below.

주의

This is a simplified quick build guide.

If you are building for production and not for home use, it's better to use autobuild scripts.

Common

The software is likely to compile and work properly on most Linux systems. It should work on macOS and even Windows.

1) Download the newest version of TOS Blockchain sources available at the GitHub repository https://github.com/tos-network/tos/:

git clone --recurse-submodules https://github.com/tos-network/tos.git

2) Install the newest versions of:

  • make

  • cmake version 3.0.2 or later

  • g++ or clang (or another C++14-compatible compiler as appropriate for your operating system).

  • OpenSSL (including C header files) version 1.1.1 or later

  • build-essential, zlib1g-dev, gperf, libreadline-dev, ccache, libmicrohttpd-dev, pkg-config

    On Ubuntu:

apt update
sudo apt install build-essential cmake clang openssl libssl-dev zlib1g-dev gperf libreadline-dev ccache libmicrohttpd-dev pkg-config

3) Suppose that you have fetched the source tree to directory ~/tos, where ~ is your home directory, and that you have created an empty directory ~/tos-build:

mkdir tos-build

Then run the following in a terminal of Linux or MacOS:

cd tos-build
export CC=clang
export CXX=clang++
cmake -DCMAKE_BUILD_TYPE=Release ../tos && cmake --build . -j$(nproc)
위험

On MacOS Intel before next step we need maybe install openssl@3 with brew or just link the lib:

brew install openssl@3 ninja libmicrohttpd pkg-config

Then need to inspect /usr/local/opt:

ls /usr/local/opt

Find openssl@3 lib and export local variable:

export OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3

If you are compiling on a computer with low memory (e.g., 1 Gb), don't forget to create a swap partitions.

Download Global Config

For tools like lite client you need to download the global network config.

Download the newest configuration file from https://tos.network/global-config.json for mainnet:

wget https://tos.network/global-config.json

or from https://tos.network/testnet-global.config.json for testnet:

wget https://tos.network/testnet-global.config.json

Lite Client

To build a lite client, do common part, download the config, and then do:

cmake --build . --target lite-client

Run the Lite Client with config:

./lite-client/lite-client -C global-config.json

If everything was installed successfully, the Lite Client will connect to a special server (a full node for the TOS Blockchain Network) and will send some queries to the server. If you indicate a writeable "database" directory as an extra argument to the client, it will download and save the block and the state corresponding to the newest masterchain block:

./lite-client/lite-client -C global-config.json -D ~/tos-db-dir

Basic help info can be obtained by typing help into the Lite Client. Type quit or press Ctrl-C to exit.

FunC

To build FunC compiler from source code, do common part described above and then:

cmake --build . --target func

To compile FunC smart contract:

func -o output.fif -SPA source0.fc source1.fc ...

Fift

To build Fift compiler from source code, do common part described above and then:

cmake --build . --target fift

To run Fift script:

fift -s script.fif script_param0 script_param1 ..

Toslib-cli

To build toslib-cli, do common part, download the config and then do:

cmake --build . --target toslib-cli

Run the toslib-cli with config:

./toslib/toslib-cli -C global-config.json

Basic help info can be obtained by typing help into the toslib-cli. Type quit or press Ctrl-C to exit.

RLDP-HTTP-Proxy

To build rldp-http-proxy, do common part, download the config and then do:

cmake --build . --target rldp-http-proxy

The Proxy binary will be located as:

rldp-http-proxy/rldp-http-proxy

generate-random-id

To build generate-random-id, do common part and then do:

cmake --build . --target generate-random-id

The binary will be located as:

utils/generate-random-id

storage-daemon

To build storage-daemon and storage-daemon-cli, do common part and then do:

cmake --build . --target storage-daemon storage-daemon-cli

The binary will be located at:

storage/storage-daemon/

Compile old TOS versions

TOS releases: https://github.com/tos-network/tos/tags

git clone https://github.com/tos-network/tos.git
cd tos
# git checkout <TAG> for example checkout func-0.2.0
git checkout func-0.2.0
git submodule update --init --recursive
cd ..
mkdir tos-build
cd tos-build
cmake ../tos
# build func 0.2.0
cmake --build . --target func

Compile old versions on Apple M1:

TOS supports Apple M1 from 11 Jun 2022 (Add apple m1 support (#401) commit).

To compile older TOS revisions on Apple M1:

  1. Update RocksDb submodule to 6.27.3

    cd tos/third-party/rocksdb/
    git checkout fcf3d75f3f022a6a55ff1222d6b06f8518d38c7c
  2. Replace root CMakeLists.txt by https://github.com/tos-network/tos/blob/c00302ced4bc4bf1ee0efd672e7c91e457652430/CMakeLists.txt