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 supported as a development platform if you only need to build C++ and Wasm targets.

Build Methods

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.

Prerequisites on macOS

  • CMake brew install cmake

  • Boost brew install boost

  • Xcode

  • Xcode command line tools: xcode-select --install

  • Ruby brew install ruby

  • Other tools: brew install git ninja autoconf automake libtool xcodegen clang-format ccache cocoapods

  • Rust: curl --proto '=https' --tlsv1.2 -sSf | sh

Prerequisites on Linux

Ubuntu as a example:

  • Various essential packages sudo apt-get install build-essential libtool autoconf pkg-config ninja-build ccache

  • Clang sudo apt-get install clang-14 llvm-14 libc++-dev libc++abi-dev

  • Ruby sudo apt-get install ruby-full

  • Boost sudo apt-get install libboost-all-dev

  • CMake sudo apt-get install cmake or (from

  • Rust: curl --proto '=https' --tlsv1.2 -sSf | sh

Managed Prerequisites

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 (gtest)

  • libcheck

  • nolhmann json

  • Protobuf

Full Build

The full build can be triggered with one top-level script:


Or, broken up in smaller steps:

## Linux

## MacOS


This script downloads and compiles some prerequisites.


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:


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.

Wasm building

Install Emscripten SDK (emsdk):


Activate emsdk:

`source emsdk/`

Build Wasm:


Run Wasm tests:

cd wasm
npm install && npm run copy:wasm && npm run build
npm run test

Testing Rust library

Rust library can be tested separately from the C++ part.

cd rust
cargo test

Checking Rust lints

We use rustfmt, clippy to check if the Rust code is formatted and does not contain common warnings/errors.

Run Rust lints:


Building inside Docker image

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

Executing inside Docker image

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


Building on Linux is possible, 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. We recommend using Ubuntu 22.04 LTS, same as Wallet Core CI.

Unit tests with Coverage

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

All CMake options


NameDescriptionHow to enable itNotes


Specify that your IDE is CLion, way to enable coverage is different on CLion


Do not enable multiple IDE options at the same time Off by default


Specify that your IDE is vscode, way to use PVS-studio is different on VSCode


Do not enable multiple IDE options at the same time Off by default


Specify that you want to use UNITY BUILD in the project, use it in order to build faster.


To be used for CI environment. Off by default


Specify that you want to build with clang-tidy static analyzer.


Do not use it at the same time as TW_ENABLE_PVS_STUDIO Clang-tidy must be installed Off by default


Specify that you want to build with pvs-studio static analyzer


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


Specify that you want to build with ASAN dynamic analyzer.


use it in Debug for optimal result. Do not mix with other runtime analyzer. Off by default


Specify that you are targeting WASM.


Off by default


Specify that you want to build with coverage support


Can be combined with TW_IDE_CLION Off by default


Specify that you want to treat all the warnings as error


Adviced to be used locally, during development. Off by default


Specify that you want to use CCACHE


On by default


Specify that you want to enable unit tests in the project


On by default on native platforms


Specify that you want to enable examples in the project


On by default on native platforms

Last updated