Evernode uses HotPocket as its smart contract engine. HotPocket smart contracts can be developed using any POSIX-compliant language/framework. Using the HotPocket developer kit, you can easily develop and test HotPocket smart contracts on your local PC.
The HotPocket developer kit requires you to install Docker Engine and NodeJs on your development machine.
The HotPocket developer kit is a global npm package which supports both Linux and Windows operating systems.
- Install prerequisites.
- Run the following command to install hpdevkit on your machine:
npm i hpdevkit -g
NOTE: In Linux platforms, installation requires root privileges. Hence, add sudo
to the above command.
You can use the HotPocket developer kit to generate smart contract projects such that everything is pre-configured. Here, we are creating a NodeJs smart contract (This assumes you have prior experience with developing NodeJs applications):
hpdevkit gen nodejs starter-contract myproj
cd myproj
npm install
npm start
The 'npm start' command will build and deploy the NodeJs smart contract into a HotPocket cluster running on your machine. It will also start printing the console output from the HotPocket instance. You can press Ctrl+C at any time to exit from monitoring the HotPocket console output. However, the HotPocket instance will continue to run even after you exit the monitoring console.
You can re-enter the monitoring console with the command hpdevkit logs 1
, where 1
is the HotPocket instance number you wish to monitor.
In order to resize the HotPocket cluster, you need to delete and re-create it:
-
Delete the existing cluster using the
hpdevkit clean
command. -
Set the HP_CLUSTER_SIZE environment variable to the size you want.
# Windows (command prompt) set HP_CLUSTER_SIZE=5 # Windows (powershell) $env:HP_CLUSTER_SIZE=5 # Linux (bash) export HP_CLUSTER_SIZE=5
-
Deploy your contract again with
npm start
.
You can use the HotPocket developer kit to generate a HotPocket client application such that everything is pre-configured. Here, we are creating a NodeJs client (This assumes you have prior experience with developing NodeJs applications):
hpdevkit gen nodejs blank-client myclient
cd myclient
npm install
node myclient.js
This will start the client application and connect a HotPocket node listening to port 8081. Also note that you need to have HotPocket nodes running on your machine for the client to connect.
# Deploy contract files directory to the cluster (`npm start` internally uses this command to deploy)
hpdevkit deploy <contract files directory>
# Stop and clean-up everything (required for changing cluster size)
hpdevkit clean
# View a specific node's logs
hpdevkit logs <node number>
# Start/stop all nodes
hpdevkit start
hpdevkit stop
# Start/stop a specific node
hpdevkit start <node number>
hpdevkit stop <node number>
# Add a new node to the cluster
# (The new node will use the existing UNL and become an observer node)
hpdevkit spawn
If the contract files directory also contains a file named hp.cfg.override
, it will be used to override the hp.cfg of all nodes. This can be used to set contract-specific parameters like 'bin_path' and 'bin_args'
An example hp.cfg.override
file for a NodeJs application (the HotPocket developer kit NodeJs starter contract automatically includes this file for you):
{
"contract": {
"bin_path": "/usr/bin/node",
"bin_args": "app.js"
}
}
You can inspect the files of all the nodes of the cluster using Docker Desktop.
hpdevkit
CLI supports the following environment variables:
Name | Description | Default value |
---|---|---|
HP_CLUSTER_SIZE | The number of nodes in the cluster. This only takes effect with a fresh cluster. | 3 |
HP_DEFAULT_NODE | The node which the 'deploy' command uses to display logs. | 1 |
HP_DEVKIT_IMAGE | The Docker image to be used for devkit cluster management. | evernodedev/hpdevkit |
HP_INSTANCE_IMAGE | The Docker image to be used for HotPocket instances. | evernodedev/hotpocket:latest-ubt.20.04-njs.20 |
HP_USER_PORT_BEGIN | The starting user port number for the cluster. | 8081 |
HP_PEER_PORT_BEGIN | The starting peer port number for the cluster. | 22861 |
Run one of the following commands to update hpdevkit
to the latest version, and update the supporting docker images:
-
Using hpdevkit CLI
hpdevkit update
-
Using npm
npm update hpdevkit -g
NOTE: You need to re-deploy your contracts for the new changes to take effect.
Run the following command to uninstall hpdevkit
and the supporting docker images and containers:
- Using hpdevkit CLI
hpdevkit uninstall
NOTE: Uninstalling from hpdevkit CLI is recommended. If you uninstall using npm, you will have to clean the hpdevkit supporting docker images and containers manually.
NOTE: In Linux platforms, you will need root privileges to execute updates and uninstallations. Hence, add sudo
to the above commands.
Report issues here.