Skip to content

Instantly share code, notes, and snippets.

@stanford-scs
Created December 19, 2022 20:49
Show Gist options
  • Save stanford-scs/cd7159102be23f3f34034dd4279806d3 to your computer and use it in GitHub Desktop.
Save stanford-scs/cd7159102be23f3f34034dd4279806d3 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
if [[ $# != 3 ]]; then
echo "usage: pay SENDER-SECRET-KEY BENEFICIARY-ADDRESS AMOUNT" >&2
exit 2
fi
SK="$1"
DEST="$2"
AMOUNT="$3"
if ! SENDER=$(echo "$SK" | stc -pub); then
echo "invalid sender secret key" >&2
exit 2
fi
TMP=`mktemp pay.XXXXXXXXXX`
trap "rm -f '$TMP'" 0
stc -o $TMP - <<EOF
tx.sourceAccount: $SENDER
tx.operations.len: 1
tx.operations[0].body.type: PAYMENT
tx.operations[0].body.paymentOp.destination: $DEST
tx.operations[0].body.paymentOp.amount: $AMOUNT
EOF
echo $SK | stc -i -sign $TMP
stc -post $TMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment