The SDK for interacting with Hedera Hashgraph: the official distributed consensus platform built using the hashgraph consensus algorithm for fast, fair and secure transactions. Hedera enables and empowers developers to build an entirely new class of decentralized applications.
For MacOS and Linux users:
- ninja
- MacOS:
brew install ninja
- Linux:
apt-get install ninja
- MacOS:
- pkg-config
- MacOS:
brew install pkg-config
- Linux:
apt-get install pkg-config
- MacOS:
- cmake
- MacOS:
brew install cmake
- Linux:
apt-get install cmake
- MacOS:
📣 Note: Ensure you install all three ninja
, pkg-config
, and cmake
to avoid errors in subsequent steps. The
installations might take a few minutes.
For Windows users:
- Visual Studio 2019/2022 Community/Pro with Universal Windows Platform Development Tools
- Perl (
perl.exe
must be added to%PATH%
) - NASM (
nasm.exe
must be added to%PATH%
)
This project features CMake Presets which simplify the setup of vcpkg based dependencies. The below commands are typically all that is required.
- Clone the project
git clone https://github.com/hashgraph/hedera-sdk-cpp.git
- CD to the project directory
cd hedera-sdk-cpp
- Complete the following tasks within your project directory for the build you want
# Ensure the VCPkg Submodule is initialized
git submodule update --init
# Windows (x64) Build
cmake --preset windows-x64-release
cmake --build --preset windows-x64-release
# Linux (x64) Build
cmake --preset linux-x64-release
cmake --build --preset linux-x64-release
# MacOS (Intel x64) Build
cmake --preset macos-x64-release
cmake --build --preset macos-x64-release
# MacOS (Aarch64) Build
cmake --preset macos-arm64-release
cmake --build --preset macos-arm64-release
To run all SDK tests (for Release or Debug builds):
ctest -C [Release|Debug] --test-dir build/<PRESET>
To run all SDK unit tests and test vectors:
ctest -C [Release|Debug] --test-dir build/<PRESET> -R "TestVectors|UnitTests"
To run all SDK integration tests:
ctest -C [Release|Debug] --test-dir build/<PRESET> -R "IntegrationTests"
To run a specific test:
ctest -C [Release|Debug] --test-dir build/<PRESET> -R <NAME OF TEST>
To run the integration tests it's necessary to have a
running Hedera Local Node. If the local node is already running, check
the configuration JSON file for the network settings. Ensure the values for network
tag contains a valid AccountId
and a valid IP address
for an operational node.
Example config file:
{
"network": {
"0.0.3": "127.0.0.1:50211"
},
"mirrorNetwork": [
"127.0.0.1:5600"
],
"operator": {
"accountId": "0.0.2",
"privateKey": "302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137"
}
}
(Source: config/local_node.json)
Examples must be run from the root directory in order to correctly access the address book and configuration files
located in the addressbook/
and config/
directories. Make sure your .env
file is populated with:
OPERATOR_ID
: The ID of the operator account.OPERATOR_KEY
: The DER-encoded hex private key of the operator account.HEDERA_NETWORK
: The Hedera network name. Must be one ofmainnet
,testnet
, orpreviewnet
.PASSPHRASE
: Optional variable used byhedera-sdk-cpp-generate-private-key-from-mnemonic-example
to generate a private key from a mnemonic with a passphrase.
The command to run an example looks like:
build/<PRESET>/sdk/examples/[Release|Debug]/<EXAMPLE_NAME>
<PRESET>
: the preset that was used to build in Step 3 under Build.[Release|Debug]
:Release
if you built inRelease
mode, otherwiseDebug
.<EXAMPLE_NAME>
: The name of the example you are trying to run.
If you're trying to run an example from the release artifacts, you must first cd
into the architecture folder of the
OS on which you are trying to run the example. For example, if you are running an x86_64
architecture on Linux
:
cd [Release|Debug]/Linux/x86_64
From there, you can run:
examples/<EXAMPLE_NAME>
NOTE: Make sure you copy your .env
file with your environment variables into this folder as well.
Additionally, the examples can be run using the run_examples
scripts(.sh
for macOS, Linux/ .bat
for Windows systems) from the project root directory. In the scripts you will find an EXECUTABLES_DIRECTORY
variable.
EXECUTABLES_DIRECTORY = <build_folder_with_exec_binaries>
Make sure to set it to the proper build folder of the binaries after building the project.
We welcome participation from all developers!
For instructions on how to contribute to this repo, please review the Contributing Guide for C++.
More instructions for contribution can be found in the Global Contributing Guide.
This project is governed by the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code of conduct.
If you need to prepare a new SDK release, then see the Step-by-Step guide how to do it.