Skip to content
Snippets Groups Projects
Commit b9b74bfa authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Deleting obsolete insert.sh and verify.sh

parent e96c4d17
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
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
contract="TimeStampAuthority"
if [ $# -eq 0 ]
then
text="Hello World!"
elif [ $# -eq 1 ]
then
text="$1"
else
contract="$1"
text="$2"
fi
prefix="${BFANETWORKDIR}/contracts"
if [ ! -e "${contract}" -a -r "${prefix}/${contract}" ]
then
contract=${prefix}/${contract}
fi
test -L "${contract}" &&
contract=$( realpath "${contract}" )
test -n "${contract}"
basecontract=$( basename "${contract}" )
test -n "${basecontract}"
abi=$( cat ${contract}/abi )
test -n "${abi}"
test -n "$text" || text="Hello World!"
js=$( mktemp )
sum=$( echo $text | sha256sum | cut -c -64 )
cleanup "$js"
cat > $js <<EOT
var mycontract = eth.contract(${abi})
var thecontract = mycontract.at("${basecontract}")
console.log ( thecontract.put.sendTransaction( "${sum}", {from: eth.accounts[0], gas: 1000000} ) )
EOT
out=$( mktemp )
cleanup "$out"
geth_exec_file "${js}" > ${out}
if [ ` wc -l < ${out} ` = 2 -a ` tail -1 < ${out} ` = "true" ]
then
trans=` head -1 < ${out} `
echo "Sent document in transaction ${trans}."
else
(
cat ${js}
echo
echo ' ***'
echo
cat ${out}
) >&2
exit 1
fi
#!/bin/bash
# 20180619 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
contract="TimestampDocument"
if [ $# -eq 0 ]
then
text="Hello World!"
elif [ $# -eq 1 ]
then
text="$1"
else
contract="$1"
text="$2"
fi
prefix="${BFANETWORKDIR}/contracts"
if [ ! -e "${contract}" -a -r "${prefix}/${contract}" ]
then
contract=${prefix}/${contract}
fi
test -L "${contract}" &&
contract=$( realpath "${contract}" )
test -n "${contract}"
basecontract=$( basename "${contract}" )
test -n "${basecontract}"
abi=$( cat ${contract}/abi )
test -n "${abi}"
test -n "$text" || text="Hello World!"
js=$( mktemp )
cleanup "$js"
cat > ${js} <<EOT
var mycontract = eth.contract(JSON.parse(${abi}))
var thecontract = mycontract.at("${basecontract}");
console.log ( thecontract.checkDocument.call( "${text}" ) )
EOT
out=$( mktemp )
cleanup "$out"
geth --datadir node1 --exec "loadScript(\"${js}\")" attach ipc:node1/geth.ipc > ${out}
if [ ` wc -l < ${out} ` = 2 -a ` tail -1 < ${out} ` = "true" ]
then
block=` head -1 < $out `
if [ "${block}" -gt "0" ]
then
echo "Document first seen in block ${block}"
else
echo "The checksum of this document has not been stored in the smart contract (yet?)."
exit 1
fi
else
(
cat ${js}
echo
echo ' ***'
echo
cat ${out}
) >&2
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment