TRON wallet installation (nodejs)

M
Muthurengan 11 months ago - Created

TRON wallet installation (nodejs)

This section looks into how to upload the source code you have downloaded to the server.We will be using the FileZilla application to upload the code with FTP as it is the easiest way to get your code up in the cloud.


1. Upload the code to server

Download FileZilla and install it on your system.

Open FileZilla and go to FileZilla>Settings.

                                                                                                                             

Go to SFTP tab.

                                                                                                                            

Press Add key filevand select your private SSH key.

You will be prompted to enter your SSH key password. Once the key is added, press OK.

Now, enter sftp://ip_address of the droplet you want to connect in the Host field and give Username as root. Press Quickconnect to establish connection.

                                        

The left panel is your local directory and your right panel is your server directory. Now drag the . you have downloaded from the left panel and drop it to /var/www/html/  folder in the right panel.

            


2. Login to the Droplet

We will connect to the server with the SSH key we added to the server in Step 1.

Copy your IP address we created in Step 1. You’ll find your IP address here:

                                             

Enter the command below in your Terminal, substituting the your_server_ip with the IP address of your Droplet for and {path_to_serverkey} with the file path of the private SSH key     we created earlier:

   $ ssh root@your_server_ip -i {path_to_serverkey} 

When done, it will look like this:                                                      

Hit Enter.You will be prompted to enter the passphrase we created while creating this private key. Enter the password and press Enter again. If you are in Mac, you might be prompted to type your keychain password.

If everything went right, you will be logged in to the server and it will look like this:

                                                      

3. Install Zip

We need to unzip the zip file we uploaded to the server in the previous step. To do so, we need to install Unzip in our server.

Enter the following commands in your Terminal and hit Enter:

sudo apt-get install zip 

4. Unzip the source code

Navigate to the HTML folder:

cd /var/www/html 

And type the unzip command in your Terminal and press Enter.

unzip {downloaded_package_file}.zip 

5. Installing package dependencies:

cd {unzipped_package_file_name}

Dependencies required for the Tron wallet to run:

1.MongoDB(v4.0) ( To navigate to the Mongo installation tap on the link)

2.Nodejs(v8.9)

Installing Nodejs using NVM

An alternative to installing Node.js through apt is to use a specially designed tool called nvm, which stands for "Node.js version manager".

Rather than working at the operating system level, nvm works at the level of an independent directory within your home directory. This means that you can install multiple, self-contained versions of Node.js without affecting the entire system. Controlling your environment with nvm allows you to access the newest versions of Node.js and retain and manage previous releases.

To start off, we'll need to get the software packages from our Ubuntu repositories that will allow us to build source packages.

sudo apt-get update

The nvm script will leverage these tools to build the necessary components:

sudo apt-get install build-essential libssl-dev

Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download it with curl:

curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh

Run the script which is downloaded from the above command with bash:

bash install_nvm.sh

To gain access to the nvm functionality use the following command,

source ~/.profile

Now that you have nvm installed, you can install isolated Node.js versions matching your scripts.

Install the nodejs version 8.9 which matches our script use command:

nvm install 8.9

When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:

node -v

you will get the output as:

Output  v8.9.*

After installing the node successfully you need to install some of the prerequisites,

Install forever:

npm install -g forever

Please make sure if you are inside the project folder by using this command:

pwd

if you are in some other directories to go to the project directory use command:

cd /var/www/html/

Next step is the configuration part, you will have to configure the essentials data's in the .env file

To check if the env file exists in your downloaded package, use command:

ls -a

you will see the file in the directory listings.

if the .env file is missing in the downloaded packages, Don't be hassle you can create a new file and include the following configuration which we have used in our application.

MONGODB_URI=mongodb://localhost:2017/tron_wallet //URL OF THE MONGODB

FULL_NODE=https://api.shasta.trongrid.io //FULL NODE API URL OF THE TRON

SOLIDITY_NODE=https://api.shasta.trongrid.io //SOLIDITY API URL OF THE TRON

EVENT_SERVER=https://api.shasta.trongrid.io //EVENT SERVER URL OF THE TRON

API_URL=https://api.shasta.trongrid.io //API URL OF THE TRON

APP_PORT=3000 //PORT NUMBER IN WHICH NODE SCRIPT SHOULD RUN ON

If you are pasting the above configurations, you can remove the comments in each line which is for your understanding,

you will have to paste the .env file like this,

MONGODB_URI=mongodb://localhost:2017/tron_wallet 

FULL_NODE=https://api.shasta.trongrid.io

SOLIDITY_NODE=https://api.shasta.trongrid.io

EVENT_SERVER=https://api.shasta.trongrid.io 

API_URL=https://api.shasta.trongrid.io

APP_PORT=3000 

After successfully configuring the .env file, you will to install the node packages which is specified in the packages.json file.

To install the node module of your project use command:

npm install

Once the node modules are installed you can start the tron wallet using command:

forever start app.js

Note: Before starting the node you will have to start the mongo db services which is explained in the above dependencies section. 

6.To check if the APIs are running ping the following address on your browser:

http://(your_ip_address}:3000/api/v1

The output will be like displayed in the image,



If you are getting the above screen, your installation is complete and good to go !!!

Was this article helpful?

0 out of 0 found this helpful

Articles in this section