Building
Find here instructions for building the Wallet Core library locally.

The following target platforms are supported:
  • iOS (Swift language is used)
  • Android
  • Wasm (Emscripten)
The following development platforms are supported:
  • macOS: is the primary development platform, as it supports compiling for both target platforms.
  • Linux: is partially supported as a development platform.

Wallet Core can be build inside a Docker image, or natively.
  • Inside Docker image: This way is easier to get the prerequisites, as they are all inside a Docker image. However, all building has to be done inside the Docker image.
  • Natively, in your dev OS (macOS, Linux).

Here is the list of required prerequisites.

  • CMake brew install cmake
  • Boost brew install boost
  • Xcode
  • Xcode command line tools: xcode-select --install
  • Other tools: brew install git ninja autoconf automake libtool xcodegen clang-format ccache cocoapods

  • Various packages sudo apt-get install autoconf git libcurl4-openssl-dev libicu-dev libssl-dev libtool ninja-build nodejs pkg-config unzip ccache
  • CLang
  • Ruby 2.6 (rbenv from https://github.com/rbenv/ruby-build, then rbenv install 2.6.3)
  • Boost (from https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz)
  • CMake (from https://github.com/Kitware/CMake/releases)

Additionally, the following prerequisites are also needed, but they are managed by Wallet Core. The script tools/install-dependencies downloads and compiles them (see below).
  • Google test
  • Check
  • Json
  • Protobuf

The full build can be triggered with one top-level script:
./bootstrap.sh
Or, broken up in smaller steps:
./tools/install-dependencies
This script downloads and compiles some prerequisites.
./tools/generate-files
This script generates source files, coin- and protobuf files. Needs to be re-run whenever registry.json or protobuf files are changed.
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug
make -Cbuild
Standard CMake and make commands for building the library. The cmake command needs to be re-run whenever a new source file is added.
After build, unit tests can be executed:
./build/tests/tests tests --gtest_filter=*
The generate-cmake-make-test steps are also available together in one script:
./tools/build-and-test
If you'd rather use and IDE for building and debugging you can specify the -G option to cmake. For instance to use Xcode call cmake -Bxcode -GXcode -DCMAKE_BUILD_TYPE=Debug and use the generated project in the xcode folder.

Install Emscripten SDK (emsdk):
`tools/install-wasm-dependencies`
Activate emsdk:
`source emsdk/emsdk_env.sh`
Build Wasm:
tools/wasm-build
Run Wasm tests:
cd wasm
npm install && npm run copy:wasm && npm run build
npm run test

Here are the instructions to build Wallet Core with the provided Dockerfile.
Prerequisite is a working Docker installation.
The command for building the Docker image:
docker build docker/wallet-core --tag wallet-core-dev
Then launch the container:
docker run -i -t wallet-core-dev /bin/bash
Inside the container the build commands can be executed (as described above; note that install-dependencies is not necessary):
cd wallet-core
./tools/build-and-test

The Docker image also contains a pre-built, runnable version of the library, so it is possible to run it, 'toy around' with it without any building. Note: this may not be the most recent version!
Unit tests and wallet console utility can be executed straight from this Docker image:
docker run -i -t trustwallet/wallet-core
cd wallet-core
./build/tests/tests tests
./build/walletconsole/walletconsole
exit

Building on Linux is possible, but not fully supported, it requires some extra work. If you have access to macOS we highly recommend developing on that platform. Using the Docker image is also recommended. Otherwise, the prerequisites have to be installed manually.

For executing tests locally with coverage measurement, some extra cmake settings are needed; see section on coverage instructions.

We enable these options on CI: -DCMAKE_BUILD_TYPE=Debug -DTW_UNITY_BUILD=ON -DTW_CODE_COVERAGE=ON -DTW_ENABLE_CLANG_TIDY=ON -DTW_CLANG_ASAN=ON
Name
Description
How to enable it
Notes
TW_IDE_CLION
Specify that your IDE is CLion, way to enable coverage is different on CLion
-DTW_IDE_CLION=ON
Do not enable multiple IDE options at the same time Off by default
TW_IDE_VSCODE
Specify that your IDE is vscode, way to use PVS-studio is different on VSCode
-DTW_IDE_VSCODE=ON
Do not enable multiple IDE options at the same time Off by default
TW_UNITY_BUILD
Specify that you want to use UNITY BUILD in the project, use it in order to build faster.
-DTW_UNITY_BUILD=ON
To be used for CI environment. Off by default
TW_ENABLE_CLANG_TIDY
Specify that you want to build with clang-tidy static analyzer.
-DTW_ENABLE_CLANG_TIDY=ON
Do not use it at the same time as TW_ENABLE_PVS_STUDIO Clang-tidy must be installed Off by default
TW_ENABLE_PVS_STUDIO
Specify that you want to build with pvs-studio static analyzer
-DTW_ENABLE_PVS_STUDIO=ON
Do not use it at the same time as TW_ENABLE_CLANG_TIDY PVS-Studio must be installed and configured. Can be combined with TW_IDE_VSCODE Off by default
TW_CLANG_ASAN
Specify that you want to build with ASAN dynamic analyzer.
-DTW_CLANG_ASAN=ON
use it in Debug for optimal result. Do not mix with other runtime analyzer. Off by default
TW_COMPILE_WASM
Specify that you are targeting WASM.
-DTW_COMPILE_WASM=ON
Off by default
TW_CODE_COVERAGE
Specify that you want to build with coverage support
-DTW_CODE_COVERAGE=ON
Can be combined with TW_IDE_CLION Off by default
TW_WARNINGS_AS_ERRORS
Specify that you want to treat all the warnings as error
-DTW_WARNINGS_AS_ERRORS=ON
Adviced to be used locally, during development. Off by default
TW_ENABLE_CCACHE
Specify that you want to use CCACHE
-DTW_ENABLE_CCACHE=ON
On by default
TW_UNIT_TESTS
Specify that you want to enable unit tests in the project
-DTW_UNIT_TESTS=ON
On by default on native platforms
TW_BUILD_EXAMPLES
Specify that you want to enable examples in the project
-DTW_BUILD_EXAMPLES=ON
On by default on native platforms
Copy link
On this page
Platforms
Build Methods
Prerequisites
Prerequisites on macOS
Prerequisites on Linux
Managed Prerequisites
Full Build
Wasm building
Building inside Docker image
Executing inside Docker image
Linux
Unit tests with Coverage
All CMake options