diff --git a/README.md b/README.md index a0782d8d50f977dea99a3e00b38ff3752e809d24..e3ccd343d0390618587ec358ee6b45e2db5a6a35 100644 --- a/README.md +++ b/README.md @@ -47,14 +47,14 @@ request: **geth** Connects you to your running local geth. -## create.contract +## compile.and.deploy.contract requires: **geth**, **solc**, **jq** Compiles and deploys a contract to the blockchain. A local "node1" must already be running and synchronized. Argument 1 is the filename of the contract to compile. -Example: `create.contract src/TimestampAuthority.sol` +Example: `compile.and.deploy.contract src/TimestampAuthority.sol` ## tsa-insert.sh requires: **geth** diff --git a/bin/create.contract b/bin/create.contract deleted file mode 100755 index f7a36c0ff88ab9452775a3aa6278b2b18678fe59..0000000000000000000000000000000000000000 --- a/bin/create.contract +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# 20180618 Robert Martin-Legene <robert@nic.ar> - -if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi -source ${BFAHOME}/bin/libbfa.sh || exit 1 - -function create -{ - workdir=$( mktemp -p . -d ) - cleanup "$workdir" - json=$( solc --optimize --combined-json abi,bin $filename ); test $? = 0 - prefix=$( echo "$json" | jq -M '.contracts | keys | .[0]' ); - abi=$( echo "$json" | jq -rM ".contracts.${prefix}.abi" ); test $? = 0 - bin=$( echo "$json" | jq -rM ".contracts.${prefix}.bin" ); test $? = 0 - # Save abi for future use - echo $abi > ${workdir}/abi - # We could save the bin, but we don't actually use it later, plus - # it gets stored in the blockchain - #echo $bin > ${workdir}/bin - js=$( mktemp ) - cleanup "$js" - cat > $js <<EOT -var mycontract = eth.contract($abi) -var transaction = mycontract.new( { from: eth.accounts[0], data: "0x${bin}", gas: 1000000 } ) -var rcpt -while ( !rcpt ) -{ - admin.sleepBlocks( 1 ) - rcpt = eth.getTransactionReceipt( transaction.transactionHash ) -} -var address = rcpt.contractAddress -var pubcontract = mycontract.at(address) -console.log( pubcontract.address ) -EOT - echo '*** Creating contract. This will take at least 16 seconds.' - outfile=$( mktemp ) - cleanup "$outfile" - geth_exec_file $js > $outfile - if [ ` wc -l < $outfile ` = 2 -a `tail -1 < $outfile` = "true" ] - then - addr=` head -1 < $outfile ` - mkdir -p ${BFANETWORKDIR}/contracts - mv ${workdir} ${BFANETWORKDIR}/contracts/${addr} - echo Your new contract can be found in ${BFANETWORKDIR}/contracts/${addr} - ln -snf ${addr} ${BFANETWORKDIR}/contracts/${contractname} - else - echo - echo ' *** INPUT ***' - echo - cat $js - echo - echo ' *** OUTPUT ***' - echo - cat $outfile - fi -} - -filename="$1" -if [ -z "$filename" -o ! -r "$filename" ] -then - echo "Specify a filename of a contract you wish to compile." - false -fi -contractname=${filename%%.sol} -contractname=${contractname##*/} -contractname=${contractname##contract.} -contractname=${contractname%.*} -bfaconfig max -prereq jq solc geth -create