A simple Ethereum based application for messaging.
The inbox.sol is written in Solidity language v0.4.17 which contains the smart contract written for messaging. This is a simple application which is deployed on ganache. You can read more about smart contracts here. You can read more about the solidity language here.
To compile the smart contract we will be using solc compiler which is used to compile solidity codes. The compile code is placed in compile.js. The code is written in JavaScript.
The lottery.test.js file, written in JavaScript tests our smart contracts by using multiple testcases written in it. We will be using mocha as the testing framework. Read more about mocha here.
The deploy.js file will deploy our smart contract to the Ganache network. It allows us to make calls to actual blockchain without the need of creating an actual node to communicate. Read more about ganaache here.
- Create a folder named Inbox in your working directory.
- Create a folder named contracts in Lottery and save our smart contract in this folder.
- Place the compile.js and deploy.js in the folder Inbox itself.
- Create a folder named test and save the lottery.test.js here.
- Install NodeJS in your computer from here. Use the recommended version.
- Install Git in your computer from here.
- Open up your cmd. Navigate to the folder Lottery in your cmd.
- Run the command- 'npm init' in our Lottery folder. This will create a package.json file in your directory.
- Install packages Truffle, Mocha, Ganache-CLI and Web3 by running the command 'npm install --save [email protected] mocha ganache-cli web3'. Truffle is a development environment, testing framework and asset pipeline for Ethereum. Mocha is a testing framework which will be required by our lottery.test.js file. Ganache provides a environment for truffle. Web3 is a collection of libraries which allows you to interact with a local or remote ethereum node.
- To compile our smart contract, run command 'node compile.js'.
- To test our smart contract, run 'npm run test'.
- Install MetaMask which is an extension for browsers like Chrome to easily track your transactions and accounts.
- Finally, deploy our contract on the Rinkeby network by running command 'node deploy.js'