|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# ~~~~~~~~~~~~ CHANGE THIS ~~~~~~~~~~~~ |
| 4 | + |
| 5 | +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 6 | + |
| 7 | +# Define directory paths |
| 8 | +keys_dir="./keys" |
| 9 | +txs_dir="./txs" |
| 10 | +tx_path_stub="$txs_dir/metadata-transaction" |
| 11 | +tx_unsigned_path="$tx_path_stub.unsigned" |
| 12 | +tx_signed_path="$tx_path_stub.signed" |
| 13 | + |
| 14 | +# Get the script's directory |
| 15 | +script_dir=$(dirname "$0") |
| 16 | + |
| 17 | +# Get the container name from the get-container script |
| 18 | +container_name="$("$script_dir/../helper/get-container.sh")" |
| 19 | + |
| 20 | +if [ -z "$container_name" ]; then |
| 21 | + echo "Failed to determine a running container." |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | + |
| 25 | +echo "Using running container: $container_name" |
| 26 | + |
| 27 | +# Function to execute cardano-cli commands inside the container |
| 28 | +container_cli() { |
| 29 | + docker exec -ti $container_name cardano-cli "$@" |
| 30 | +} |
| 31 | + |
| 32 | +echo "Building transaction" |
| 33 | + |
| 34 | +container_cli conway transaction build \ |
| 35 | + --tx-in $(container_cli conway query utxo --address $(cat $keys_dir/payment.addr) --out-file /dev/stdout | jq -r 'keys[0]') \ |
| 36 | + --change-address $(cat $keys_dir/payment.addr) \ |
| 37 | + --metadata-json-file "$txs_dir/metadata.json" \ |
| 38 | + --out-file "$tx_unsigned_path" |
| 39 | + |
| 40 | +container_cli conway transaction sign \ |
| 41 | + --tx-body-file "$tx_unsigned_path" \ |
| 42 | + --signing-key-file $keys_dir/payment.skey \ |
| 43 | + --out-file "$tx_signed_path" |
| 44 | + |
| 45 | +# Submit the transaction |
| 46 | +echo "Submitting transaction" |
| 47 | + |
| 48 | +container_cli conway transaction submit --tx-file $tx_signed_path |
0 commit comments