This repository contains material to teach you Smart Contract development workflow using Ganache CLI, Web3 v1, SolcJS and Solium.
It is slightly more complex than using Truffle for contract deployment. But it is necessary for first-timers so they can grasp the foundational knowledge about various core concepts of Ethereum and how to work with them.
You should already have NodeJS and NPM installed on your machine.
git clone
this repository on to your workstation.- Run npm commands to install global modules (ganache-cli, solium) and local ones (solc, web3, readline-sync) and create solium config files (
solium --init
). Either do these yourself (recommended) or runprerequisites.sh
. - View
hello-world-contract.sol
once. - Lint the contract with Solium for security checks using
solium -f hello-world-contract.sol
. Fix any issues being shown. - In a separate window, launch ganache with 1st account unlocked using
ganache-cli --unlock 0
. - Run
deployer.js
script. Keep pressing ENTER or giving inputs where asked. - See CLI logs & ganache outputs side-by-side to understand the actions being performed.
deployer.js
is an interactive application that walks you through:
- Programmatically compiling your solidity smart contract
- Deploying it through an Ethereum Node (Ganache CLI for development)
- Reading State Variable from the deployed Contract
- Modifying the state of the contract by making a transaction to change the state variable's value
- Re-reading the variable to see the reflected changes
This script expects an ethereum node running on http://localhost:8545/
(so run Ganache before running it).
NOTE: The coinbase account is the default primary local account on an Ethereum node. This is not to be confused with coinbase website.
hello-world-contract.sol
is the Smart Contract we'll be deploying on the ethereum blockchain (simulated by Ganache). (We will first lint this contract for style & security using Solium).
prerequisites.sh
is a simple Bash script that installs the necessary NPM dependencies and sets up solium configuration files. It is to be run before running deployer.js
. We recommend you run all the commands from this file yourselves so you know all the actions being performed prior to deploying a contract to ethereum blockchain.
See the ico
branch in this repository.