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

POC insert and verify scripts for the TSA

parent 90b697b3
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"
contract=${BFANETWORKDIR}/contracts/${contract}
contract=$( realpath "${contract}" )
test -r "${contract}"
basecontract=$( basename "${contract}" )
test -n "${basecontract}"
abi=$( cat ${BFANETWORKDIR}/contracts/${basecontract}/abi )
test -n "${abi}"
hashes=
while read -p :
do
sum=$( echo -n "$REPLY" | sha256sum | cut -c -64 )
echo $sum
hashes="$hashes,web3.toDecimal(\"0x$sum\")"
done
hashes="${hashes:1}"
echo $hashes
js=$( mktemp )
cleanup "$js"
cat > $js <<EOT
var mycontract = eth.contract(${abi})
var thecontract = mycontract.at("${basecontract}")
console.log( thecontract.put.sendTransaction( [${hashes}], {from: eth.accounts[0], gas: 1000000} ) )
EOT
out=$( mktemp )
cleanup "$out"
geth_exec_js "${js}" > ${out}
if [ ` wc -l < ${out} ` = 2 -a ` tail -1 < ${out} ` = "true" ]
then
trans=` head -1 < ${out} `
echo "Sent checksum(s) in transaction ${trans}."
else
(
cat ${js}
echo
echo ' ***'
echo
cat ${out}
) >&2
exit 1
fi
#!/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"
contract=${BFANETWORKDIR}/contracts/${contract}
contract=$( realpath "${contract}" )
test -r "${contract}"
basecontract=$( basename "${contract}" )
test -n "${basecontract}"
abi=$( cat ${BFANETWORKDIR}/contracts/${basecontract}/abi )
test -n "${abi}"
hashes=
sum=$( echo -n "$1" | sha256sum | cut -c -64 )
echo $sum
hashes="web3.toDecimal(\"0x$sum\")"
echo $hashes
js=$( mktemp )
cleanup "$js"
cat > $js <<EOT
var mycontract = eth.contract(${abi})
var thecontract = mycontract.at("${basecontract}")
console.log( thecontract.get.call( [${hashes}], {from: eth.accounts[0], gas: 1000000} ) )
EOT
out=$( mktemp )
cleanup "$out"
geth_exec_js "${js}" > ${out}
if [ ` wc -l < ${out} ` = 2 -a ` tail -1 < ${out} ` = "true" ]
then
block=` head -1 < $out `
if [ "${block}" -gt "0" ]
then
echo "Checksum first seen in block ${block}"
else
echo "The checksum 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