Setting up the development environment
This chapter explains how to set up OrbiterSDK to start creating and deploying your contracts in it. This is an overview/"more approachable" version of the project's README.md file - be sure to read it as well.
OrbiterSDK is our open-core blockchain SDK project. You're able to tweak out almost everything related to it. That includes but it isn't limited to:
- Consensus
- Block processing
- Transaction processing
- Contract processing
- Communication between nodes, etc.
We offer pre-existing solutions for all of those, but you are free to change them as you wish, as long you don't break your own blockchain. TODO: what is this last part supposed to be?
As OrbiterSDK is not running a virtual machine of any kind, it is impossible to submit a transaction with bytecode for a respective contract. Contracts are natively compiled with the blockchain itself, which requires them to exist alongside the project's source code.
Because of that, we strongly encourage you to fork the project, play around with the code and start developing your own contracts.
In order to fork the project, you can head over to the GitHub repository and click on the "Fork" button. After that, you can clone your forked repository and start developing on your own.
OrbiterSDK requires several dependencies (as of v0.0.1):
- GCC with support for C++20 or higher
- CMake 3.19.0 or higher
- Abseil (absl)
- Boost 1.74 or higher (components: chrono, filesystem, program-options, system, thread, nowide)
- CryptoPP 8.2.0 or higher
- gRPC + Protobuf 3.12 or higher + libc-ares
- LevelDB + libsnappy
- libscrypt
- OpenSSL 1.1.1
- zlib
Here's a one-liner that should work on Debian 11 (Bullseye) or greater, as well as its derived distributions:
sudo apt install build-essential cmake tmux clang-tidy autoconf libtool pkg-config libabsl-dev libboost-all-dev libc-ares-dev libcrypto++-dev libgrpc-dev libgrpc++-dev libleveldb-dev libscrypt-dev libsnappy-dev libssl-dev zlib1g-dev openssl protobuf-compiler protobuf-compiler-grpc
Note that Debian 11 specifically ships CMake 3.18.4, which is not enough for OrbiterSDK's 3.19.0 requirement. In this case, you'll need to either install it separately, or compile it from source.
First, make sure you've uninstalled the system's CMake with
sudo apt purge cmake
, to avoid conflicts.We recommend downloading the installer from CMake's website, installing it to somewhere like
/opt
and symlinking it to /usr/local
, like so (change $CMAKEVER
for the version number you wish):# Assume CMAKEVER=3.19.0
# Download CMake installer
wget https://github.com/Kitware/CMake/releases/download/v$CMAKEVER/cmake-$CMAKEVER-linux-x86_64.sh
# Make it executable
chmod +x ./cmake-$CMAKEVER-linux-x86_64.sh
# Run it with the following parameters
sudo ./cmake-$CMAKEVER-linux-x86_64.sh --prefix=/opt --include-subdir --skip-license
# Symlink the CMake executable so you can call it directly
sudo ln -s /usr/local/bin/cmake /opt/cmake-$CMAKEVER-linux-x86_64/bin/cmake
# Symlink other binaries here if you wish
If you want to compile it from source, follow the steps below. They will install CMake 3.26.3, but you can change the version to any other you want like it was done above:
# Download CMake source
wget https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3.tar.gz
# Extract the cmake-3.26.3.tar.gz file
tar -zxvf cmake-3.26.3.tar.gz
# Go to the extracted directory
cd cmake-3.26.3
# Bootstrap CMake (use --parallel=X where X is the number of cores you want to use to speed up the process)
./bootstrap --parallel=$(nproc)
# Compile CMake (use -jX where X is the number of cores you want to use to speed up the process)
make -j$(nproc)
# Install CMake
sudo make install
After forking the project, you are now able to setup your own local testnet. This is strongly recommended, as it will ensure your environment is properly setup and that you are able to compile the project with your contracts in it.
Clone your forked repository by following the steps below:
# Clone your repository
git clone https://github.com/YOUR_USER_NAME/orbitersdk-cpp.git
# Go to the project directory
cd orbitersdk-cpp
# Fetch all tags
git fetch --tags upstream
# Switch to a branch for contract development on latest release (change the version accordingly)
git checkout -b contract-development v0.0.1
After cloning, the following commands will build the project within the folder which
AIO-setup.sh
(a script that automatically deploys a local testnet) will use later.# Create the folder and enter it
mkdir build_local_testnet && cd build_local_testnet
# Configure cmake (DEBUG=ON will enable debug symbols and address sanitizer)
cmake -DDEBUG=ON ..
# Build the project - you can use either one of the lines below
make -j$(nproc)
# or...
cmake --build . -- -j$(nproc)
After building, you can optionally run a test bench with the following command:
./orbitersdkd-tests -d yes
(the -d yes
parameter will give a verbose output).To deploy the local testnet,
cd
back to the project's root folder and run ./scripts/AIO-setup.sh
. The script will setup a local testnet with the following information. TODO: shouldn't this info be here?After that, you can connect any Web3 client to the local testnet. We recommend using Metamask as it is the most popular one, but you can use any other you want.
Running the script again will stop the testnet, rebuild it, replace it and restart it on the spot. If you wish to manually stop the testnet for some reason, call
tmux kill-server
(as we use tmux to properly deploy it). You can also read the script to find out the specific names of the tmux sessions.Here's how to configure MetaMask to connect to your local testnet:
Field | Value |
---|---|
Network Name | OrbiterSDK Local Testnet |
New RPC URL | |
Chain ID | 808080 |
Currency Symbol | SPARQ |
Then, import the following private key for the Chain Owner account, which contains 1000 SPARQ Tokens and can call ContractManager:
0xe89ef6409c467285bcae9f80ab1cfeb3487cfe61ab28fb7d36443e1daa0c2867
Last modified 1mo ago