-
Notifications
You must be signed in to change notification settings - Fork 13
/
register-beacon-script.sh
executable file
·64 lines (53 loc) · 2.05 KB
/
register-beacon-script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
## Variables
dir="../../../ignored/swap-files/"
tmpDir="../../../ignored/tmp/"
beaconScriptFile="${dir}twoWayBeacons.plutus"
# Export the beacon script.
echo "Exporting the beacon script..."
cardano-swaps scripts two-way beacon-script \
--out-file $beaconScriptFile
# Create the registration certificate
cardano-cli stake-address registration-certificate \
--stake-script-file $beaconScriptFile \
--out-file "${tmpDir}registration.cert"
# Create the transaction.
echo "Exporting the current protocol parameters..."
cardano-swaps protocol-params \
--testnet \
--out-file "${tmpDir}protocol.json"
initial_change=$((59627618-2000000)) # registration requires 2 ADA deposit.
echo "Building the initial transaction..."
cardano-cli transaction build-raw \
--tx-in e39e1414f0ba51220be1e1a11b8379a3ef629ebb6bca8d4e11ad11076c762263#1 \
--tx-out "$(cat ../../../ignored/wallets/01.addr) + $initial_change lovelace" \
--certificate-file "${tmpDir}registration.cert" \
--protocol-params-file "${tmpDir}protocol.json" \
--fee 0 \
--out-file "${tmpDir}tx.body"
echo "Calculating the required fee..."
req_fee=$(cardano-cli transaction calculate-min-fee \
--tx-body-file "${tmpDir}tx.body" \
--testnet-magic 1 \
--protocol-params-file "${tmpDir}protocol.json" \
--tx-in-count 2 \
--tx-out-count 2 \
--witness-count 1 | cut -d' ' -f1)
echo "Building the final transaction..."
cardano-cli transaction build-raw \
--tx-in e39e1414f0ba51220be1e1a11b8379a3ef629ebb6bca8d4e11ad11076c762263#1 \
--tx-out "$(cat ../../../ignored/wallets/01.addr) + $((initial_change-req_fee)) lovelace" \
--certificate-file "${tmpDir}registration.cert" \
--protocol-params-file "${tmpDir}protocol.json" \
--fee "$req_fee" \
--out-file "${tmpDir}tx.body"
echo "Signing the transaction..."
cardano-cli transaction sign \
--tx-body-file "${tmpDir}tx.body" \
--signing-key-file ../../../ignored/wallets/01.skey \
--testnet-magic 1 \
--out-file "${tmpDir}tx.signed"
echo "Submitting the transaction..."
cardano-swaps submit \
--testnet \
--tx-file "${tmpDir}tx.signed"