VeChain SOLO development environment

MiRei
9 min readMay 14, 2019

--

This guide will show every step to install a VeChain Thor environment based on a solo network. It is intended to get everything up and running fast and show how the different programs interact with each other. The SOLO network is a sandbox development mode for the VeChain Thor blockchain, that can be started (and is only available) on a single server. It is not publicly accessible and the generated blocks will be lost if the SOLO node is stopped.

Part 1 — Install VeChain Thor software

Part 1.1 — Install Debian 9 x64

VeChain can run on many different systems, including various Linux distributions and Windows. This guide however will focus on Debian 9 but should be easily adaptable to any other distribution. The installation of the base system will not be described here, since there are a lot of good guides out there but the following points should be kept in mind before the installation of the base system:

  • VeChain Thor can be I/O intensive and should be installed on SSD-based storage with at least 30GB
  • At least 2 CPUs and 4GB of RAM should be avalible (for this SOLO setup)

After the installation is done, the system will be updated and the needed packages will be added.

### Update System and install dependencies (as root)
apt-get update
apt-get -y install build-essential libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev git libcap2-bin
apt autoremove -y
apt-get clean

(Check here for a Windows Guide: https://medium.com/@michael_81043/how-to-build-and-use-vechain-thor-in-microsoft-windows-d538c66390e6)

Part 1.2 — Install VeChain Thor Node software

VeChain is build in GO. So before installing VeChain, GO needs to be set up. Since there is no appropriate Debian package for GO, it will be installed as followed:

### Install go (as root)
cd ~
wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz
chmod +x /usr/local/go/bin/go
rm go1.10.3.linux-amd64.tar.gz
### Install dep (as root)
cd /usr/local/bin/
wget https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64
ln -s dep-linux-amd64 dep
chmod +x /usr/local/bin/*

For security reasons, the VeChain Thor software itself will not run as root. Therefore a new user “thor-node” will be added and the needed environmet variables for GO will be set:

### Add Thor-Node user (as root)
useradd -m -d /home/thor-node -s /bin/bash thor-node
su - thor-node
### Set environment paths (as thor-node)
cd ~
touch ${HOME}/.profile
echo "export PATH=$PATH:/usr/local/go/bin" >> ${HOME}/.profile
echo "export GOPATH=$HOME/go" >> ${HOME}/.profile
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
mkdir -p $GOPATH/src
source .profile

The Vechain software is downloaded from the official github and then installed:

### Install VeChain (as thor-node)
git clone https://github.com/vechain/thor.git $GOPATH/src/VeChain/thor
cd $GOPATH/src/VeChain/thor
make dep
make all

Part 1.3 — Start VeChain Thor SOLO node

Now that everything is set up, the solo node can be started.

The following command will run the solo node in the terminal and make it accessible on every IP on the system:

./go/src/VeChain/thor/bin/thor solo --api-addr 0.0.0.0:8669

After this command, the following output should appear:

Start of the VeChain Thor Solo Node

Part 1.4 — Understanding the SOLO node

The SOLO mode has some special features that need to be known before working with it:

  1. A SOLO network has always the same ten “MasterWallets”. VET/VTHOR is generated on these addresses in the genesis block. A list of these addresses is shown on each start of the SOLO network.
  2. A SOLO network has a fixed Block-Gas-Limit of 10.000.000
  3. If the Thor-Node process is stopped, all data will be lost!

Part 2 —Connect Sync to the SOLO network

Sync is a multi-purpose wallet for the VeChain Thor Blockchain. It also has an integrated serverless blockexplorer that can be connected to the SOLO network. Sync is availible for Windows/Mac/Linux. In this guide, the Windows version will be used.

Part 2.1 — Install Sync and connect it to the SOLO networks

  • Sync can be downloaded here: GitHub
  • After the installation, Sync should look like this:

To make Sync interact with the SOLO network, the ip-address of the system where thor was installed is needed. On Linux systems this can be done with “ifconfig”, on Windows systems this can be done with “ipconfig”. For this guide the ip-address will be 172.17.7.29

To change the Sync-Server, the green “Main” button and the gearwheel needs to be clicked.

Add a SOLO Node to Sync

Through “add Node” the connection details can be entered.

Add a SOLO Node to Sync

The SOLO node can be activated by clicking the green “Main” and choose the newly added node.

If done correctly, insight will display blocks from the solo node

Part 2.2 — Add MasterWallets to Sync

To interact with the SOLO node, addresses with VET/VTHOR are needed. As mentioned earlier, a SOLO node always has ten Masterwallets. These addresses are static to everyone and must not be used in Test- or Mainnet! At least one Wallet is needed in Sync to interact with it. These are the ten MasterWallets:

Click the wallets symbol in the upper right, then import

Choose “Private Key” and enter one of the private keys from the table above.

Give the wallet a name and a password and click “import”

A wallet should now be visible in Sync

VeChain Thor SOLO MasterWallet

Part 3 — Interact with the SOLO Node using Sync

Part 3.1 — Send VET/VTHOR using Sync

This will show the basic usage of the two native tokens on VeChain. Vet and Vthor.

Send VET using Sync

Choose a imported Masterwallet and click “Transfer”.

Enter the recipient addess and the amount to sent.

Enter the Password given to the MasterWallet where VET is send from and sign

After Switching to “insight”, the new transaction should be visible under “Recent Transfers”

Send VTHOR using Sync

To send VTHOR, the destination address needs to be opened in Insight. In this example, 0xD3ae78222BEADB038203bE21eD5ce7C9B1BfF602 will be the destination.

Enter the destination address into the searchbar and press enter.

Click on “Deposit” and enter the VTHO amount.

Sign the transaction.

Part 3.2 — Deploy a smart contract to the SOLO network through Sync

Sync can also deploy smart contracts to the blockchain. For that the ABI and the ByteCode are needed. This is specific to Solidity and will be done in this guide with a simple Token contract as an example.

Import SourceCode into Remix

The smart contract source code needs to be converted to ABI und ByteCode. Since VeChain is 100% ERC20 compatible, the most convinient way of doing this, is through Remix.

  • Compiler Version needs to be set to 0.4.24
  • Code just needs to be imported to a file called SimpleToken.sol and then be compiled (warnings can be ignored)

Get ByteCode and ABI

The ByteCode is needed to deploy the smart contract. To get it in the format compatible with sync, click “Details” and scroll to ByteCode”.

To make the ByteCode work with Sync “0x” needs to be added in front of it, resulting in the following string.

The ABI can be recived by simply clicking “ABI” right next to “Details” and looks like this:

Deploy a Smart Contract using Sync

If ByteCode and ABI are available, the ByteCode needs to be sent to the SOLO network. This can be done with “Inspector”, available in the AppHub included in Sync.

Open Inspector

Open “Inspector”, click “Deploy”, paste the appropriate ByteCode and click “Send”.

Send ByteCode through VeChain Sync Inspector

The wallet that signs the transaction HAS TO BE 0x7567d83b7b8d80addcb281a71d54fc7b3364ffed to work with the pre-compiled ByteCode provided above.

Sign transaction to create SmartContract

The new SmartContract address can be found by clicking on the arrow in the upper right and inspecting the latest transaction.

Find new SmartContract address
Find new SmartContract address

Import Smart Contract to Sync

To be able to interact with the new smart contract, Sync (Inspector) has to be made aware of it. This can be done by opening “Inspector”, clicking “Contracts” and then “Add”. The address is the smart contract addres, that was checked in the previous image.

Add ABI to VeChain Inspector

Part 3.3 — Interact with the Smart Contract

The “SimpleToken” contract is now visible in “Inspector” and Sync can interact with it.

Get the Token name from the contract

The first interaction with the smart contract is simply getting the name of the Smart Contract token. Since this is a “read”, there is no update needed and no transaction is needed for this. This can be done by expanding the “name” routine and clicking “Call”. The result of this call is shown in HEX at the “data” field and decoded for humans in the “decoded” field.

Check token balance of an empty wallet

To verify that the state of the smart contract can be changed, an address (in this guide 0xd3ae78222beadb038203be21ed5ce7c9b1bff602) is checked that should have 0 token now. This can be done with the “balanceOf” function.

Send token to an empty wallet

Now a contract “write” is needed. Inspector seperates “reads” and “writes”.

The “transfer” function can be found in the “writes” tab. As destination, the previously checked empty wallet is entered. The token has 18 decimal digits. So 18 zeros needs to be added to the actual amount. In this guide, 10 tokens will be send, resulting in a value of 10000000000000000000.

Now the transaction can be executed

Check destination wallet

If the transaction is executed successfully, a new check of the token balance should show the appropriate value.

--

--