Ravi Valecha
3 min readJul 22, 2020

Implement Smart Contracts using solidity

A custom node project for implementing a smart contract includes following components

Contract Creation — Create a smart contract using solidity

Local Testing — Test scripts to compile, execute and test the smart contracts

Deployment — Deployment scripts to compile and deploy the contracts on ethereum test network.

There are some issue and solutions with implementation of smart contract using JavaScript,

Need to write the Solidity code in JavaScript, how is it possible to compile the solidity code. The solution here is to setup the solidity compiler to build the smart contracts.

Need some way to rapid test smart contracts without any manual testing, Remix is the tool used to create smart sontract and for manual testing. The solution here is to setup a custom Mocha test runner that some how test solidity smart contract

Need some way to deploy the smart contract to public etherueum network. The solution here is to set up a compile and deployment coontract script to public network.

Create a project in NodeJS. Prerequisite to start before implementation of smart contract —

npm init ( create a nodeJS project)

npm install — save solc@0.4.25 ( Solidity Compiler)
npm install — save ganache-cli (Ganache CLI)

npm install — save web3 (Web3)

Project directory structure of nodeJS application —

Smart Contract

to setup the solidity compiler to build the smart contracts, write a compile script which use solc compiler to compile and build the smart contracts. Build interface of smart contract is assigned to “module.export” , to access it from other scripts

to setup a custom Mocha test runner that some how test solidity smart contract . Install mocha.

Ganache CLI, made by the Truffle team, is an essential tool for Ethereum development and testing.When you boot up Ganache, it gives you 10 Ethereum wallets that each contain 100 fake ETH. You can use this test net ETH to test smart contracts on your localhost blockchain.

to deploy the smart contract to public etherueum network, configure infura to communicate with ethereum network.

Infura — It is a set of tools for anyone to create an application that connects to the Ethereum blockchain. It interacts with the Ethereum blockchain and runs nodes on behalf of its users. Use infura to deploy the smart contracts on ethereum network