Welcome to this quick start guide to developing applications on the Vechain Thor blockchain platform.
The purpose of this guide is to serve as a quick way to set up your developer environment by installing all the needed tools to develop dApps on the Vechain platform. You will get a good understanding how the various components work together.
[fruitful_alert color=”alert-info”]Basic blockchain knowledge is required to follow this guide, and throughout this guide we assume you are running a Linux OS (Ubuntu), but it’s also possible to follow this guide when running Windows or macOS.[/fruitful_alert]Interacting with the blockchain
When you want to call a function on a smart contract, you need to query one of the Vechain hor Nodes and tell it:
- The address of the smart contract.
- The function you want to call.
- The variable you want to send to that function.
To communicate with the Nodes we need to use the RESTful API. Thorify is an application that extends on web3 to allow us to directly communicate with the RESTful API.
Install nodejs
sudo apt-get install nodejs
a
sudo apt-get install npm
install web3
sudo apt-get install git
a
npm install web3
a
npm install --save thorify
asu
Installing VS Code
To write code we need an IDE (Integrated development environment)
https://linuxize.com/post/how-to-install-visual-studio-code-on-ubuntu-18-04/
Setting up your own Local VechainThor Node
See the official installation guide on https://github.com/vechain/thor.
- Please see this guide on how to set up your own Thor Node using Docker.
- Please see this guide on how to set up your own Thor Node on Amazon Cloud.
Creating Smart Contracts
Smart contracts on the Vechain Thor blockchain are run on the Ethereum Virtual Machine, a lightweight operating system that is specially created to run smart contracts.
Solidity is a programming language with a syntax similar to JavaScript that allows programmers to create smart contracts. Popular programs to write smart contracts are Truffle and Remix.
Smart contracts are deployed by sending a transaction to the blockchain in which the receiver address is empty and the data field contains the compiled code of the contract to be created.
To communicate with the Nodes to for example send a transaction and to deploy a contract we need to use Thor’s RESTful API. Web3-Gear is an application developed to allow Truffle and Remix to communicate with Thor’s RESTful API. It converts Ethereum RPC calls to VechainThor RPC calls.
How to install web3-Gear
To install web3-Gear we first have to install its dependencies LibSSL and Python
sudo apt-get install libssl-dev
Install the Python installer pip by running
sudo apt install python3-pip
After this we can install Web3-Gear and it’s dependent Python packages via Pypi
pip3 install web3-gear
Run and Setup web3-Gear
You can run web3 gear with the following command. Please make sure you run the Thor client first or you will get the ” unable to connect to Thor-Restful server” message.
web3-gear
By default, this will start web3-gear on 127.0.0.1:8545. To change the default behavior the following parameters are accepted:
- –host: rpc service host, eg:
--host 127.0.0.1
- –port: rpc service port, eg:
--port 8545
- –endpoint: thor restful service endpoint, eg:
--endpoint http://127.0.0.1:8669
- –keystore: keystore file path, eg:
--keystore /Users/(username)/keystore)
, default=thor stand-alone(solo) built-in accounts - –pascode: passcode of keystore, eg:
--passcode xxxxxxxx
Setup Remix or Truffle
Use Remix
Change the Remix environment to Web3 provide.
Use Truffle
- Truffle 4.0.6+ support
npm install -g truffle
Modify the configuration of truffle first(truffle.js
):
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};
Then you can use truffle’s command line tool.
Really clear web site, regards for this post.
Just wish to say your article is as surprising. The clearness on your submit is just excellent and i can suppose you’re knowledgeable in this subject. Well together with your permission let me to take hold of your RSS feed to stay up to date with forthcoming post. Thank you one million and please keep up the rewarding work.
You are my intake, I possess few blogs and occasionally run out from to brand : (.
Thank you for the good writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how could we communicate?