Skip to content

Server with node and express to send commands and queries to contracts in Vara Network

Notifications You must be signed in to change notification settings

Vara-Lab/Node-Express-Sails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express Node Sails

Web server with node and express that contains paths to each command and queries from a contract (In this case Traffic light contract)

This script contains necessary functions as well as examples to be able to communicate with a contract, using commands and queries.

Table of contents:

Instalation

  1. You need to go to the directory where you will download the repository.
  2. Once you are in the directory, you need to run the following command in your terminal:
git clone https://github.com/Vara-Lab/Node-Express-Sails.git
  1. Next, you have to enter in the directory created by git, using:
cd Node-Express-Sails
  1. WIth this, you can now set the environment!

Setting the environment

You need to install Node 18 or above.

  • To install the project dependencies, run the following command in your terminal:
yarn

if you don't have yarn installed, you need to execute the next command to install yarn globally:

npm i -g yarn

Setting the signer

In the node server, you will need the wallet data that will sign the messages in the script, you have to set the wallet name and the wallet mnemonic to create the signer from that data.

To set this filds, you have to go to the src/consts.ts file, and put the wallet data in the constants: WALLET_NAME and WALLET_MNEMONIC:

export const WALLET_NAME: string = ''; // set the wallet name
export const WALLET_MNEMONIC: string = ''; // set the wallet mnemonic

compilation and execution

To compile the node server, you need to run the following command in your terminal:

yarn tsc

And to run the node server (after running it, it's important to compile it first), you need to execute the next command in your terminal:

yarn start

With this step, you will see how the server starts and show you the link to use it.

Node server links

You can use this example links to check the functionality of the server.

Files and directories

  • contract-methods directory: This directory contains the commands and queries of the contract to be executed.
  • paths directory: This directory contains all "routers" for node to be used in the server.
  • consts.ts file: In this file you will find all the constants that you can use in the script, you can change it to set your contract data.
  • utils.ts file: In this file you will find some helper functions that will help you to handle some common aspects, like create a new GearAPi instance, Sails instance, etc.
  • index.ts file: Here you will find the main functions that will execute the script to send al the messages and queries to the contract.

About

Server with node and express to send commands and queries to contracts in Vara Network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published