0chain/gosdk
The 0chain client SDK is written in GO.
This repository currently supports the following platforms:
- OSX Mojave 10.14.5
- LINUX (Ubuntu/bionic).
-
- This includes all Ubuntu 18+ platforms, so Ubuntu 19, Linux Mint 19 etc. (apt based package installer)
- ADDED
- LINUX (RHEL/CENTOS 7+)
-
- All Releases based on RHEL 7+, Centos 7+, Fedora 30 etc. (yum based package installer)
See Step-by-Step Installation guide plus Deployment Guide at bottom
It is possible to support the sdk for other variations of Linux as well.
Build and Installation
0chain/gosdk is build and installed using GNU Make.
The Makefile has following targets to ease installation of build tools and the 0chain/gosdk.
Success of installation of the library and GO modules is highly dependent upon the prior installed
packages on the developer system.
These steps have been tested out thoroughly on OSX Mojave 10.14.5 and Vanilla Ubuntu BIONIC.
0chain/gosdk has heavy dependency on BLS and MCL
provided by MITSUNARI Shigeo. Developers should refer to those links when they encounter any errors.
Please send email to alphanet@0chain.net if you encounter any problems.
TARGET |
Description |
build-tools |
Install go, jq and supporting tools |
install |
Install herumi and gosdk |
install-herumi |
Build, Test and Install the herumi library |
install-gosdk |
Build and test 0chain gosdk modules |
clean |
Delete all the build output |
FAQ
sudo apt-get install build-essential
sudo snap install go --classic
STEP BY STEP INSTALLATION GUIDE
Note: The following guide accommodates many different Linux distros/installations. You may see error messages, primarily with yum based installation. In particular, the default method tries to use snap to install go platform but we install it directly with yum method.
Ubuntu/Debian Based e.g. Ubuntu, Mint, debian (using apt package manager)
sudo apt update
sudo apt-get install build-essential
sudo apt install git
RHEL Based e.g. Centos, RedHat, Fedora (using yum package manager)
Assume superuser privilege (alternatively, prefix necessary commands with sudo e.g. sudo yum update -y)
su
Install Essential Tools (Note some of these will already be installed depending on distribution)
yum update -y
yum install -y openssl-devel
yum groupinstall -y "Development Tools"
yum install -y git
yum install -y wget
yum install -y make
yum install -t g++
Install go platform
wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz
rm go1.13.linux-amd64.tar.gz
Set up paths, this needs to be done each session. Alternatively, append paths in $HOME/.bash_profile
export PATH=$PATH:/usr/local/go/bin
export LD_LIBRARY_PATH=/usr/local/lib
Set Up directories and clone gosdk
(Common) starting in $HOME folder
mkdir go
cd go
mkdir github.com
cd github.com
mkdir 0chain
cd 0chain
git clone https://github.com/0chain/gosdk.git
(Common) starting in 0chain folder
cd gosdk
make build-tools
make install
make install-herumi
make install-gosdk
make clean
cd ..
Test SDK (Optional)
(Common) starting in 0chain folder
cd gosdk/_sdkver
go build -o sdkver sdkver.go
cd ../..
gosdk/_sdkver/sdkver
(Should output SDK version if successful)
(Common) starting in 0chain folder
ZBox:-
git clone https://github.com/0chain/zboxcli.git
cd zboxcli
go build -tags bn256 -o zbox
To test:-
./zbox
Then back to 0chain folder:-
cd ..
Zwallet
git clone https://github.com/0chain/zwalletcli.git
cd zwalletcli
go build -tags bn256 -o zwallet
You will at least require $HOME/.zcn folder with nodes.yaml file present to test wallet (change this as required)
mkdir $HOME/.zcn
cp sample/config/devb.yml $HOME/.zcn/nodes.yaml
To test:-
./zwallet
Then back to 0chain folder:-
cd ..
DEPLOYMENT GUIDE
- Target Machine must be recent kernel as distributions mentioned, (specifically libc6 version >= 2.27?)
NOTE: Do not attempt to install libc version into older Linux installation (unless you know what you are doing) as it can mess up your system
Supported platforms all of the above e.g.
- RHEL7+, Centos7+, Ubuntu18+, Mint19+, Fedora30+ (and derivatives)
PLUS
Copy these files From/To /usr/local/lib
libmcl.so
libbls256.so
Perform this command on target machine for each session required or add path in $HOME/.bash_profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
Adjust permissions for user as needed.
Copy other files as required, e.g.
zbox
zwallet
nodes.yaml
into folder
$HOME/.zcn