Last active
September 9, 2016 08:22
-
-
Save fredead/182f0efa5f346e960175902faba0fab6 to your computer and use it in GitHub Desktop.
Ethereum compile with solc and deploy using geth
This file contains hidden or 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/sh -e | |
TEMPDIR=`mktemp -d` | |
echo Compilecode | |
solc --gas --bin -o ${TEMPDIR} $1 | |
FILENAME=${TEMPDIR}/$1 | |
FILENAME=`echo ${TEMPDIR}/$1 | sed -e 's/.sol$/.bin/'` | |
DATA=`cat $FILENAME` | |
echo "Unlock account" | |
geth --exec 'personal.unlockAccount(eth.coinbase)' attach ipc:/opt/geth/geth.ipc | |
TRANSACTIONID=`geth --exec "eth.sendTransaction({from: eth.coinbase, \"gas\": \"0x220000\", \"data\": \"0x${DATA}\" })" attach ipc:/opt/geth/geth.ipc` | |
echo "transaction completed is ${TRANSACTIONID}" | |
sleep 50 | |
geth --exec "eth.getTransactionReceipt(${TRANSACTIONID})" attach ipc:/opt/geth/geth.ipc | grep contractAddress | |
rm -Rf ${TEMPDIR} | |
# Calling a contract | |
# get abi | |
# solc --abi *.so | |
# This generates a file use contents with contractAddress about in geth | |
# > var MyContract = eth.contract(<contents of abi file above).at(<contractAddress>) | |
# now to call | |
# Mycontract.<function>(var1,var2,...., { from: <fromhash> }) | |
# Mycontract.<function>.sendTransaction(var1,var2,...., { from: <fromhash> }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment