Other Functionalities

We can also use truffle and vyper language for deployment of smart contract. Here are the steps for how to deploy smart contract in truffle.

First we do Contract Deployment Using Truffle:

For this CROSSVALUE Chain Smart Contract truffle tutorial, we will require 4 important applications:

  • NodeJS

  • NPM

  • Truffle

  • Solidity Compiler

Installing NodeJS

NodeJS is a JavaScript Framework that is used to build server applications. As we are using a private network, NodeJS will make it easy to build the network application.

To install Nodejs, run the following command in your terminal:

Installing NPM

NPM stands for Node Package Manager and is used to run Nodejs applications.

To install NPM, run the following command in your terminal:

Installing Truffle

Truffle is a Development Environment.

To install Truffle, run the following command in your terminal:

Installing Solidity Compiler

Solidity is a programming language used to write Smart Contracts. To run smart contracts on our system, we have to install Solidity Compiler.

To install Solidity Compiler, run the following command in your terminal:

Connecting Geth to CROSSVALUE Chain:

Geth console is the console from where we can interact with the CROSSVALUE Chain. To connect Geth to the CROSSVALUE Chain, open a new terminal and run the below command:

Creating Truffle Project

To start with this, let us first create a new directory to store the Truffle project. And then in that directory, we will create a new Truffle project. Open a new terminal and run the below commands:

The truffle init command will create all the necessary files required for a truffle project.

Now that we have everything to deploy Smart Contract ready, let’s get to write a “Hello World” Smart Contract.

Configuring Truffle Migration

To migrate our Smart Contract, we will have to add a file in the “migrations” directory in the “truffle” directory. In this directory we will add a file named “2_deploy_contracts.js” with the following contents in it:

To run truffle on our network, we need to edit the “truffle.js” file in the “truffle” directory. Open this file and make the following entries:

Compiling and Deploying Smart Contract

Before we can execute our Smart Contract, we have to first compile and deploy it to our CROSSVALUE Chain Network. We will do this using the following command:

and then, go back to the terminal which has “truffle” as the present working directory and run the following command:

Now check the contract deployment in CVC blockchain.

Finally our smart contract is deploy using truffle.

Last updated