DEV Community

Cover image for Deploying 'HelloWorld' on Vapory
Marlon Hanks
Marlon Hanks

Posted on

Deploying 'HelloWorld' on Vapory

Vapory is a new blockchain with a growing set of supporting technology. This tutorial covers the basics of deploying a smart contract on the Vapory Network using Node.js, Gvap, and the Vapory Flavored Solidity Compiler. Vapory currently offers no public network for testing and only miners produce the vapors needed to publish HelloWorld. Vapory was developed by an army of two and the status of the network can be checked anytime at

Step One - Create a Vapory Development Environment

This article will not cover every step in the methods of forging the perfect development environment for Vapory. There are simply too many external variables to factor into the action of doing so.
It will cover the versions used by the author to provide guidance enough to execute success.

Ubuntu is the OS of choice used by the Vapory Team. 20.04 was used for this article. Windows 10 works just fine with Vapory. GCC (Ubuntu 9.3.0-17ubuntu1~20.04) / Clang (10.0.0-4ubuntu1) and Go (version go1.15.6 linux/amd64) are required to build Gvap ( on Linux. Vapory.js ( and Vapory Web3.js ( suggest support of Node.js LTS/Fermium, however, this real world exercise proved that there are several issues to resolve with those packages. Being that Node.js LTS/Dubnium is stable for use of Vapory JS Modules, it was selected for deployment. Refer to the Vapory Wiki ( on how to setup gvap to serve rpc requests and create accounts using the JavaScript console.

Step Two - Build the Vapory Flavored Solidity Compiler

If no other version of Solidity is present on the system, the compiler may be installed using:

npm install -g @vapory/solc
Enter fullscreen mode Exit fullscreen mode

If any other version Solidity is currently installed, the Vapory Flavored Solidity Compiler should be independently built to avoid the resulting system conflicts that will arise in not doing so. Download Boost 1.65.1 from and then extract the archive to a location of choice. Build boost using these two commands:

./b2 -j 4
Enter fullscreen mode Exit fullscreen mode

Now download the compiler from or clone it from and enter its directory. Execute the following commands on Ubuntu:

git submodule update --init --recursive
mkdir build
cd build
BOOST_ROOT=<boost directory> cmake .. && make
Enter fullscreen mode Exit fullscreen mode

Voila! Vapory Flavored Solidity (solc) will now be in the solc directory. Execute solc --help to confirm that the compiler functions on the system.

Step Three - Create a Vapory Smart Contract Node.js Package

A Node.js package is not necessarily required to use Node.js to deploy a smart contract to the Vapory Network. It is required to remove the warnings received while installing the dependencies for Vapory Web3.js when using Node.js and is just good practice. For this tutorial, Version 0.20.4-b of Vapory Web3.js was utilized and it may be installed using:

npm install @vapory/web3@0.20.4-b --save
Enter fullscreen mode Exit fullscreen mode

Within this package create hello.sol and add the following as its contents:

// HelloWorld
pragma solidity >=0.4.0 <0.7.0;
contract HelloWorld {
    function get()public pure returns (string memory){
        return 'Hello World!';
Enter fullscreen mode Exit fullscreen mode

Now create deploy.js and add the following as its contents:

// Copyright 2017 - MIT licensed
// Run with Node 7.x as:
// node --harmony-async-await  deploy.js

let fs = require("fs");
let Web3 = require('@vapory/web3'); 

// Create a vapory web3 connection to a running gvap node over JSON-RPC running at
// http://localhost:8575
// For geth VPS server + SSH tunneling see
let web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8575'));

// Read the compiled contract code
// Compile with
// solc SampleContract.sol --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,srcmap,srcmap-runtime,userdoc > contracts.json
let source = fs.readFileSync("contracts.json");
let contracts = JSON.parse(source)["contracts"];
// ABI description as JSON structure
let abi = JSON.parse(contracts['hello.sol:HelloWorld'].abi);

// Smart contract VVM bytecode as hex
let code = '0x' + contracts['hello.sol:HelloWorld'].bin;

// Create Contract proxy class
let SampleContract = web3.vap.contract(abi);

// Unlock the coinbase account to make transactions out of it
console.log("Unlocking coinbase account");
var password = "";
try {
  web3.personal.unlockAccount(web3.vap.coinbase, password,300);
} catch(e) {

console.log("Deploying the contract");
let contract ={from: web3.vap.coinbase, gas: 1000000, data: code});
// Transaction has entered to gvap memory pool
console.log("Your contract is being deployed in transaction at" + contract.transactionHash);
function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));

// We need to wait until any miner has included the transaction
// in a block to get the address of the contract
(async function () {
  while (true) {
    var deploy = {from:web3.vap.coinbase, data:code, gas: 2000000};
    var getVContractInstance ='', deploy);
    let receipt = web3.vap.getTransactionReceipt(getVContractInstance.transactionHash);
    if (receipt && receipt.contractAddress) {
      console.log("Your contract has been deployed at" + receipt.contractAddress);
      console.log("Note that it might take 30 - 90 sceonds for the block to propagate befor it's visible in");
    console.log("Waiting a mined block to include your contract... currently in block " + web3.vap.blockNumber);
    await sleep(10000);
})().catch( e => { console.error(e) });
Enter fullscreen mode Exit fullscreen mode

The password should be set to corresponding credentials

Step Four - Compile and Deploy the Vapory Smart Contract

Compile hello.sol using the following command:

solc hello.sol --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,srcmap,srcmap-runtime,userdoc > contracts.json
Enter fullscreen mode Exit fullscreen mode

Next - deploy:

node deploy.js
Enter fullscreen mode Exit fullscreen mode

A Transaction Hash will output along with an expected Node.js error. Due to the current state of the Vapory Network, timing deployments can be tricky. Normally results are expected in less than 10 seconds. However, some deployments may take ten minutes as Vapory is just too new. Timing will improve as more nodes come online. Until that growth occurs, the sleep function must be adjusted to avoid the node.js error. If the error is encountered, don't fret, the smart contract is most likely deployed.

Step Five - Confirm your Transaction on Vaporscan

Deploy.js will output a url directing to Vaporscan ( with the corresponding transaction hash. At the time of writing this article, Vaporscan reached an age of one week and does not yet have an intuitive presentation to view and interact with Vapory Smart Contracts. One will need to write the code for that.

Discussion (0)