Last active
March 25, 2018 17:15
-
-
Save ketankr9/4f2e1c0c2d726246e00da40ab060e22b to your computer and use it in GitHub Desktop.
A simple bash script which processes all the sequence of programs required to run while ethereum smart contract developement.
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
#!/bin/bash | |
############################################################################################################ | |
# The sequence of steps followed while developing and testing smartContracts are: | |
# 0. Starting the private network via ganache-cli | |
# 1. Modification of solidity code(.sol) or frontend(.html) file | |
# 2. Compilation of the solidity code(.sol) which generates (.abi) and (.bin) file with the contract's name | |
# 3. Changing frontend(.html) file such that the new (.abi) and code(.bin) is reflected. | |
# 4. Restarting HTTPServer such that the changes are reflected | |
# 5. Opening the browser and entering the ip:port | |
############################################################################################################ | |
# Basically the above 6 sequence is combined sequencially and executed at once. | |
# Provided you html file, solidity file, and contract address have the same name defined below as fname | |
############################################################################################################ | |
fname="question1" | |
solc --overwrite -o . --bin --abi $fname.sol | |
code=$(cat $fname.bin) | |
sed -i -e "s/^\s\{4\}var\scode\s=\s".*";$/ var code = \"$code\";/" $fname.html | |
abi=$(cat $fname.abi) | |
sed -i -e "s/^\s\{4\}var\sabi\s=\s.*;$/ var abi = $abi;/" $fname.html | |
# check if ganache is already running | |
numG=$(ps -ef | grep -c "ganache-cli") | |
# if not running then start ganache-cli or display the ganache-cli process | |
if [ "$numG" -eq 1 ] | |
then | |
ganache-cli & | |
else | |
echo "Ganache Already Running" | |
ps -ef | grep "ganache-cli" | head -n$(($numG-1)) | |
fi | |
# upload to Server Where The question is hosted via sftp protocol | |
# uncomment below if wanted this feature | |
#scp -r ~/ctf/q1/examples/question1.html root@[your_server_ip]:~/ | |
# check if python server is running | |
numP=$(ps -ef | grep -c "SimpleHTTPServer") | |
# check if python SimpleHTTPServer is already running | |
if [ "$numP" -gt 1 ] | |
then | |
ps -ef | grep "SimpleHTTPServer" | head -n$(($numP-1)) | |
echo "python SimpleHTTPServer already running, restarting..." | |
ps -ef | grep "SimpleHTTPServer" | head -n$(($numP-1)) | awk '{print$2}' | xargs kill | |
fi | |
python -m SimpleHTTPServer 8080 & | |
firefox http://localhost:8080/ | |
#sleep infinity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment