This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.25; | |
contract Message { | |
string public message; | |
constructor(string memory _message) public { | |
message = _message; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs-extra"); | |
const {web3} = require("./web3"); | |
const compileContract = require("./build/Message.json"); | |
// Contract object deployed on network (ganache-cli or testnet or mainnet) | |
// network can be selected in web3 file | |
// cont | |
const getContractObject = () => { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "docker-ethereum", | |
"version": "1.0.0", | |
"description": "", | |
"main": "./server/index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "nodemon ./server/index.js" | |
}, | |
"author": "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const router = express.Router(); | |
const compile = require("../../ethereum/compile"); | |
const deploy = require("../../ethereum/deploy"); | |
// Compile the contract | |
router.post("/compile", async function(req, res, next) { | |
const result = compile(); | |
res.send(result); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const router = express.Router(); | |
const logic = require("../../ethereum/logic"); | |
router.get("/", async (req,res,next) => { | |
let message = await logic.getMessage(); | |
res.send(message); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const bodyParser = require("body-parser"); | |
const cors = require("cors"); | |
const app = express(); | |
const contractAPIRoutes = require("./routes/contract-API"); | |
const smartContractAPIRoutes = require("./routes/smart-contract-API"); | |
const port = 4000; |
OlderNewer