### Compile and Start Trust Wallet Core Source: https://github.com/trustwallet/wallet-core/blob/master/samples/go/dev-console/README.md Steps to compile the wallet core, prepare the environment, build the development console, and start it. ```bash `${PROJECT_ROOT}/bootstrap.sh` ./prepare.sh cd cmd && go build -o ../tw_dev_console && cd - ./tw_dev_console ``` -------------------------------- ### Installation Rules Source: https://github.com/trustwallet/wallet-core/blob/master/CMakeLists.txt Defines the installation rules for the TrustWalletCore target, specifying library, archive, and header file destinations. ```cmake install(TARGETS TrustWalletCore LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/WalletCore FILES_MATCHING PATTERN "*.h" ) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ``` -------------------------------- ### Install Trust Wallet Core with WebAssembly Support Source: https://github.com/trustwallet/wallet-core/blob/master/wasm/README.md Installs the Trust Wallet Core library, which includes beta support for WebAssembly, using npm. ```bash npm install @trustwallet/wallet-core ``` -------------------------------- ### Serve Wasm Sample Source: https://github.com/trustwallet/wallet-core/blob/master/samples/wasm/README.md Starts a local HTTP server to serve the Wasm sample application, typically for testing in a web browser. ```shell python3 -m http.server 8000 ``` -------------------------------- ### Full Wallet-Core Build Script Source: https://github.com/trustwallet/wallet-core/blob/master/samples/go/README.md Executes the top-level bootstrap script to perform a full build of the wallet-core library. This script handles the compilation and setup required for using the library. ```shell ./bootstrap.sh ``` -------------------------------- ### NPM Integration Source: https://github.com/trustwallet/wallet-core/blob/master/README.md Instructions for installing the Trust Wallet Core library for Node.js projects using npm. ```javascript npm install @trustwallet/wallet-core ``` -------------------------------- ### Install Wasm Dependencies Source: https://github.com/trustwallet/wallet-core/blob/master/samples/wasm/README.md Installs the necessary dependencies for building the Wasm components of the Trust Wallet Core library. ```shell tools/install-wasm-dependencies ``` -------------------------------- ### Install Flutter Dependencies Source: https://github.com/trustwallet/wallet-core/blob/master/flutter/README.md Installs the necessary dependencies for the Flutter project using Dart's package manager. ```bash dart pub get ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/trustwallet/wallet-core/blob/master/CMakeLists.txt Initializes the CMake project, sets the minimum version, and defines the project name. It also includes compiler checks to ensure Clang is used. ```cmake cmake_minimum_required(VERSION 3.18 FATAL_ERROR) project(TrustWalletCore) if (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")) message(FATAL_ERROR "You should use clang compiler") endif () ``` -------------------------------- ### Clone and Build Wallet-Core Sample App Source: https://github.com/trustwallet/wallet-core/blob/master/samples/osx/README.md Steps to clone the Wallet-Core repository, navigate to the macOS sample directory, and install dependencies using CocoaPods. ```shell git clone https://github.com/trustwallet/wallet-core.git cd wallet-core/samples/osx/cocoapods pod install ``` -------------------------------- ### Troubleshoot macOS Compilation Error Source: https://github.com/trustwallet/wallet-core/blob/master/samples/go/dev-console/README.md Command to resolve a 'go build' error on macOS related to 'golang.org/x/sys'. ```go go get -u golang.org/x/sys ``` -------------------------------- ### Install walletconsole Executable Source: https://github.com/trustwallet/wallet-core/blob/master/walletconsole/CMakeLists.txt Specifies the installation command for the walletconsole executable, placing it in the binary directory defined by CMAKE_INSTALL_BINDIR during the installation process. ```cmake INSTALL(TARGETS walletconsole DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### Setting Installation Prefix Source: https://github.com/trustwallet/wallet-core/blob/master/CMakeLists.txt Configures the installation prefix for the project. It defaults to a local build directory if the PREFIX environment variable is not set. ```cmake if (NOT ("$ENV{PREFIX}" STREQUAL "")) set(PREFIX "${CMAKE_SOURCE_DIR}/build/local") else () set(PREFIX "$ENV{PREFIX}") endif () ``` -------------------------------- ### Add Example Test Source: https://github.com/trustwallet/wallet-core/blob/master/tests/CMakeLists.txt Adds a CTest test named 'example_test' that executes the 'tests' executable. ```cmake add_test(NAME example_test COMMAND tests) ``` -------------------------------- ### Building Protobuf Code Generation Plugins Source: https://github.com/trustwallet/wallet-core/blob/master/protobuf-plugin/CMakeLists.txt Builds two executable plugins: 'protoc-gen-c-typedef' and 'protoc-gen-swift-typealias'. These plugins are linked against the Protobuf libraries (libprotobuf and libprotoc) and are installed into the 'bin' directory. ```cmake add_executable(protoc-gen-c-typedef c_typedef.cc) target_link_libraries(protoc-gen-c-typedef protobuf::libprotobuf protobuf::libprotoc) add_executable(protoc-gen-swift-typealias swift_typealias.cc) target_link_libraries(protoc-gen-swift-typealias protobuf::libprotobuf protobuf::libprotoc) install(TARGETS protoc-gen-c-typedef protoc-gen-swift-typealias DESTINATION bin) ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/trustwallet/wallet-core/blob/master/samples/cpp/CMakeLists.txt Sets up the CMake project, specifies the minimum required version, and defines project name. It also enforces the use of the Clang compiler and requires the WALLET_CORE build directory to be provided. ```cmake cmake_minimum_required (VERSION 3.8 FATAL_ERROR) project (wallet-core-demo-cpp) if (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")) message(FATAL_ERROR "You should use clang compiler") endif() set (SETUP_MESSAGE "Please provide TrustWalletCore build directory with -DWALLET_CORE. Example: cmake . -DWALLET_CORE=../wallet-core") if (NOT WALLET_CORE) message (FATAL_ERROR "${SETUP_MESSAGE}") endif () ``` -------------------------------- ### CMake Build Configuration for TrustWalletCoreProtobufPlugin Source: https://github.com/trustwallet/wallet-core/blob/master/protobuf-plugin/CMakeLists.txt Configures the CMake build environment for the TrustWalletCoreProtobufPlugin project. It sets the minimum CMake version, project name, macOS deployment target, C++ standard to C++20, and determines the installation prefix based on the environment variable PREFIX. ```cmake cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(TrustWalletCoreProtobufPlugin) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version" FORCE) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) if("$ENV{PREFIX}" STREQUAL "") set(PREFIX "${CMAKE_SOURCE_DIR}/../build/local") else() set(PREFIX "$ENV{PREFIX}") endif() find_package(Protobuf CONFIG REQUIRED PATH ${PREFIX}/lib/pkgconfig) ``` -------------------------------- ### Run Go Sample Integration Source: https://github.com/trustwallet/wallet-core/blob/master/samples/go/README.md Compiles and runs the Go sample integration with Wallet-Core. It first navigates to the Go samples directory, builds the main executable, and then runs it to demonstrate core functionality like mnemonic validation and Bitcoin network interaction. ```shell cd wallet-core/samples/go go build -o main ./main ``` -------------------------------- ### Run the Sample Application Source: https://github.com/trustwallet/wallet-core/blob/master/samples/cpp/README.md Command to execute the compiled C++ sample application. ```shell ./sample ``` -------------------------------- ### Clone and Build Wallet-Core Source: https://github.com/trustwallet/wallet-core/blob/master/samples/cpp/README.md Steps to clone the Wallet-Core repository and build the sample C++ application. Requires specifying the path to the Wallet Core library. ```shell git clone https://github.com/trustwallet/wallet-core.git cd wallet-core/samples/cpp cmake . -DWALLET_CORE=../../ make ``` -------------------------------- ### Launch Wallet Console Source: https://github.com/trustwallet/wallet-core/blob/master/walletconsole/README.md Demonstrates how to launch the Wallet Console utility from the command line. ```bash $ ./build/walletconsole/walletconsole ``` -------------------------------- ### Go Integration Sample Source: https://github.com/trustwallet/wallet-core/blob/master/README.md Reference to the Go integration sample for Trust Wallet Core, located in the project's samples directory. ```go # Check out the Go integration sample: https://github.com/trustwallet/wallet-core/tree/master/samples/go ``` -------------------------------- ### Build and Run Rust Application Source: https://github.com/trustwallet/wallet-core/blob/master/samples/rust/README.md Commands to build and run the Rust sample application that links with the wallet-core library. Assumes wallet-core is in the parent directory. ```bash cargo build cargo run ``` -------------------------------- ### Build Project using Gradle CLI Source: https://github.com/trustwallet/wallet-core/blob/master/samples/kmp/README.md This snippet illustrates the command to build the project using Gradle from the command line. It also shows a typical output indicating a successful build process, including daemon startup and task execution. ```bash ./gradlew assemble Starting a Gradle Daemon (subsequent builds will be faster) Authenticating user: ... ...BUILD SUCCESSFUL in 1m 30s 178 actionable tasks: 46 executed, 132 up-to-date ``` -------------------------------- ### Clone and Navigate Wallet-Core Repository Source: https://github.com/trustwallet/wallet-core/blob/master/samples/go/README.md Clones the wallet-core repository from GitHub and changes the current directory into the cloned repository. This is a prerequisite for building and running the Go sample. ```shell git clone https://github.com/trustwallet/wallet-core.git cd wallet-core ``` -------------------------------- ### Conditional Subdirectory Inclusion Source: https://github.com/trustwallet/wallet-core/blob/master/CMakeLists.txt Conditionally includes subdirectories for tests, wallet console examples, and static analysis tools based on CMake variables. ```cmake if (TW_UNIT_TESTS) add_subdirectory(tests) endif () if (TW_BUILD_EXAMPLES) add_subdirectory(walletconsole/lib) add_subdirectory(walletconsole) endif () if (TW_ENABLE_PVS_STUDIO) tw_add_pvs_studio_target(TrustWalletCore) endif () if (TW_ENABLE_CLANG_TIDY) tw_add_clang_tidy_target(TrustWalletCore) endif () ``` -------------------------------- ### Kotlin Multiplatform Integration Sample Source: https://github.com/trustwallet/wallet-core/blob/master/README.md Reference to the Kotlin Multiplatform integration sample for Trust Wallet Core, located in the project's samples directory. ```kotlin # Check out the Kotlin Multiplatform sample: https://github.com/trustwallet/wallet-core/tree/master/samples/kmp ``` -------------------------------- ### Wallet Console Set Coin and Get Address Source: https://github.com/trustwallet/wallet-core/blob/master/walletconsole/README.md Illustrates setting the active coin to Bitcoin and retrieving the default address. ```plaintext > coin btc Set active coin to: bitcoin > addrDefault Result: bc1q2kecrqfvzj7l6phet956whxkvathsvsgn7twav ``` -------------------------------- ### Finding TrustWalletCore Libraries Source: https://github.com/trustwallet/wallet-core/blob/master/samples/cpp/CMakeLists.txt Locates the TrustWalletCore and wallet_core_rs libraries using `find_library`. If not found, it throws a fatal error, guiding the user to provide the correct build directory. ```cmake find_library(WALLET_CORE_LIB_FILE TrustWalletCore PATH ${WALLET_CORE}/build) if (NOT WALLET_CORE_LIB_FILE) message (FATAL_ERROR "TrustWalletCore library not found. ${SETUP_MESSAGE}") else () message ("TrustWalletCore library found here: ${WALLET_CORE_LIB_FILE}") endif () find_library(WALLET_CORE_RS_LIB_FILE wallet_core_rs PATH ${WALLET_CORE}/rust/target/release) if (NOT WALLET_CORE_RS_LIB_FILE) message (FATAL_ERROR "wallet_core_rs library not found. ${SETUP_MESSAGE}") else () message ("wallet_core_rs library found here: ${WALLET_CORE_RS_LIB_FILE}") endif () ``` -------------------------------- ### Compile Protobuf Files for Transactions Source: https://github.com/trustwallet/wallet-core/blob/master/samples/go/README.md Compiles the protobuf files located in the 'src/proto' directory. This step is necessary for enabling transaction functionality on different blockchain networks and can be customized as needed. ```shell ./compile.sh ``` -------------------------------- ### Executable Definition and Linking Source: https://github.com/trustwallet/wallet-core/blob/master/samples/cpp/CMakeLists.txt Defines the main executable 'sample' and links it with the necessary TrustWalletCore libraries, TrezorCrypto, protobuf, pthread, and platform-specific libraries. ```cmake # sources of this exec add_executable (sample sample.cpp) # link with our library, and default platform libraries target_link_libraries (sample PUBLIC TrustWalletCore ${WALLET_CORE_RS_LIB_FILE} TrezorCrypto protobuf pthread ${PLATFORM_LIBS}) ``` -------------------------------- ### Ed25519 Testing Source: https://github.com/trustwallet/wallet-core/blob/master/trezor-crypto/crypto/ed25519-donna/README.md Details on how to build and run tests for the Ed25519 implementation, including sanity tests, benchmarks, and internal math primitive testing. ```bash gcc ed25519.c -DED25519_TEST -o test_ed25519 ./test_ed25519 ``` -------------------------------- ### Copy Wasm Sample Source: https://github.com/trustwallet/wallet-core/blob/master/samples/wasm/README.md Copies the Wasm sample files into the appropriate directory for the project. ```shell npm run copy:wasm-sample ``` -------------------------------- ### GitHub Package Registry Authentication Source: https://github.com/trustwallet/wallet-core/blob/master/samples/kmp/README.md This code snippet demonstrates how to set up authentication for the GitHub Package Registry by adding your GitHub username and a non-expiring, read-only token to the `local.properties` file. This is crucial for accessing private packages. ```java gpr.user= gpr.key= ``` -------------------------------- ### Build Wasm Components Source: https://github.com/trustwallet/wallet-core/blob/master/samples/wasm/README.md Compiles the Wasm components for the Trust Wallet Core library. ```shell tools/wasm-build ``` -------------------------------- ### Contributing to Wallet Core Source: https://github.com/trustwallet/wallet-core/blob/master/README.md Guidelines for contributing code to the Wallet Core project, including how to submit feedback and report bugs. ```markdown If you want to contribute code please see [Contributing](https://developer.trustwallet.com/wallet-core/contributing). ``` -------------------------------- ### Manual Protobuf Plugin Invocation Source: https://github.com/trustwallet/wallet-core/blob/master/protobuf-plugin/README.md Demonstrates the command-line invocation of the Protobuf plugin to generate typedefs. It specifies input directories, the plugin executable, output directory, and the main Protobuf definition file. ```bash protoc -I=../../src --plugin=protoc-gen-int=protoc-gen-int --int_out ../../include/TrustWalletCore ../../src/TrustWalletCore.proto ``` -------------------------------- ### Project Information Configuration Source: https://github.com/trustwallet/wallet-core/blob/master/docs/registry-fields.md Specifies various URLs related to the project, including the main website, source code repository, RPC service, and documentation site. ```json { "info": { "url": "", "source": "", "rpc": "", "documentation": "" } } ``` -------------------------------- ### Wallet Core on Windows Source: https://github.com/trustwallet/wallet-core/blob/master/README.md Community effort to provide Wallet Core support for the Windows platform. ```markdown - Wallet Core on Windows https://github.com/kaetemi/wallet-core-windows ``` -------------------------------- ### Verify KMM Environment with kdoctor Source: https://github.com/trustwallet/wallet-core/blob/master/samples/kmp/README.md This snippet shows how to use the `kdoctor` tool to diagnose and verify your system's readiness for Kotlin Multiplatform Mobile development. It checks for essential components like the operating system, Java, Android Studio, Xcode, and CocoaPods. ```bash ╰─$ kdoctor Environment diagnose (to see all details, use -v option): [✓] Operation System [✓] Java [✓] Android Studio [✓] Xcode [✓] Cocoapods Conclusion: ✓ Your system is ready for Kotlin Multiplatform Mobile Development! ``` -------------------------------- ### Including CMake Modules Source: https://github.com/trustwallet/wallet-core/blob/master/CMakeLists.txt Includes standard CMake modules for settings, compiler warnings, static analyzers, and finding host packages. ```cmake include(GNUInstallDirs) include(cmake/StandardSettings.cmake) include(cmake/CompilerWarnings.cmake) include(cmake/StaticAnalyzers.cmake) include(cmake/FindHostPackage.cmake) ``` -------------------------------- ### Build walletconsolelib Library Source: https://github.com/trustwallet/wallet-core/blob/master/walletconsole/lib/CMakeLists.txt This snippet configures the CMake build system to create the 'walletconsolelib' library. It finds all .cpp files recursively, adds them to the library, and links necessary external libraries like TrezorCrypto, TrustWalletCore, protobuf, and Boost. ```cmake file(GLOB_RECURSE walletconsolelib_sources *.cpp) add_library(walletconsolelib ${walletconsolelib_sources}) target_link_libraries(walletconsolelib TrezorCrypto TrustWalletCore protobuf Boost::boost) target_include_directories(walletconsolelib PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) ```