Skip to content

Instantly share code, notes, and snippets.

View schadokar's full-sized avatar
😵

Shubham Chadokar schadokar

😵
View GitHub Profile
@schadokar
schadokar / web3.js
Created April 11, 2019 13:49
web3 provider
// web3.js
const fs = require("fs");
const Web3 = require("web3");
const web3Network = "ganache"
// creating a web3 instance on ganache-cli network
// Here the url is http://ganache:8545
// this ganache is the name of the container in which ganache-cli is running
const web3 = new Web3(new Web3.providers.HttpProvider("http://ganache:8545"))
@schadokar
schadokar / deploy.js
Created April 11, 2019 13:33
Deploy the smart contract to the ethereum network
const fs = require("fs-extra");
const path = require("path");
const {web3, web3Network} = require("./web3");
const compiledContract = require("./build/Message.json");
const circularJSON = require('circular-json');
const deploy = async (mymessage) => {
try {
// set the receipt path
const receiptPath = path.resolve("ethereum","receipt-"+web3Network+".json");
@schadokar
schadokar / compile.js
Last active April 11, 2019 09:16
Compile the smart contract
const fs = require("fs-extra");
const path = require("path");
const solc = require("solc");
const compile = () => {
try {
// build path where compiled contract will save
const buildPath = path.resolve(__dirname,"./build");
// remove the build folder if it exist
@schadokar
schadokar / Message.sol
Created April 11, 2019 08:17
Message Smart Contract
pragma solidity ^0.4.25;
contract Message {
string public message;
constructor(string memory _message) public {
message = _message;
}
@schadokar
schadokar / Dockerfile.ganache
Created April 11, 2019 08:15
Dockerfile for the ganache-cli image
# base image - node:alpine
FROM node:alpine
# set the working directory to /app
WORKDIR /app
# install ganache-cli globally
RUN npm install -g ganache-cli
# set the command ganache-cli -h 0.0.0.0