-
Notifications
You must be signed in to change notification settings - Fork 721
/
deregister-stake-address.sh
executable file
·87 lines (68 loc) · 2.91 KB
/
deregister-stake-address.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
set -e
# Unofficial bash strict mode.
# See: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -u
set -o pipefail
export BASE="${BASE:-.}"
export WORK="${WORK:-example/work}"
export CARDANO_NODE_SOCKET_PATH="${CARDANO_NODE_SOCKET_PATH:-example/node-bft1/node.sock}"
export TESTNET_MAGIC="${TESTNET_MAGIC:-42}"
export UTXO_VKEY1="${UTXO_VKEY1:-example/shelley/utxo-keys/utxo1.vkey}"
export UTXO_SKEY1="${UTXO_SKEY1:-example/shelley/utxo-keys/utxo1.skey}"
utxoaddr=$(cardano-cli address build --testnet-magic "$TESTNET_MAGIC" --payment-verification-key-file "$UTXO_VKEY1")
scriptpaymentaddrwithstakecred=$(cardano-cli address build --payment-verification-key-file "$UTXO_VKEY1" --stake-script-file "scripts/plutus/scripts/guess-42-stake.plutus" --testnet-magic 42)
stakingscriptaddr=$(cardano-cli stake-address build --stake-script-file scripts/plutus/scripts/guess-42-stake.plutus --testnet-magic 42)
# DEREGISTRATION
# Update UTxO again
echo ""
echo "Script staking address deregistration"
echo ""
cardano-cli query utxo \
--address "$utxoaddr" \
--cardano-mode \
--testnet-magic "$TESTNET_MAGIC" \
--out-file "$WORK/utxo-2.json"
cat "$WORK/utxo-2.json"
txinupdated3=$(jq -r 'keys[0]' "$WORK/utxo-2.json")
txincollateral=$(jq -r 'keys[1]' "$WORK/utxo-2.json")
echo ""
echo "Selected txin: $txinupdated3"
# Create deregistration certificate
cardano-cli stake-address deregistration-certificate \
--stake-script-file "scripts/plutus/scripts/guess-42-stake.plutus" \
--out-file "$WORK/script.deregcert"
# Get PParams
cardano-cli query protocol-parameters --testnet-magic "$TESTNET_MAGIC" --out-file "$WORK/pparams.json"
cardano-cli transaction build \
--alonzo-era \
--testnet-magic "$TESTNET_MAGIC" \
--change-address "$utxoaddr" \
--tx-in "$txinupdated3" \
--tx-in-collateral "$txincollateral" \
--tx-out "$scriptpaymentaddrwithstakecred+500" \
--witness-override 3 \
--certificate-file "$WORK/script.deregcert" \
--certificate-script-file "scripts/plutus/scripts/guess-42-stake.plutus" \
--certificate-redeemer-file "scripts/plutus/data/42.redeemer" \
--protocol-params-file "$WORK/pparams.json" \
--out-file "$WORK/script-deregistration-cert.txbody"
cardano-cli transaction sign \
--tx-body-file "$WORK/script-deregistration-cert.txbody" \
--testnet-magic "$TESTNET_MAGIC" \
--signing-key-file "$UTXO_SKEY1" \
--out-file "$WORK/script-deregistration-cert.tx"
cardano-cli transaction submit \
--tx-file "$WORK/script-deregistration-cert.tx" \
--testnet-magic "$TESTNET_MAGIC"
echo "Staking script adress"
echo "$stakingscriptaddr"
echo "Waiting 5 seconds..."
sleep 5
echo "Check to see if the script staking address was successfully deregistered"
cardano-cli query stake-address-info \
--address "$stakingscriptaddr" \
--testnet-magic 42 \
--out-file "$WORK/scriptderegistration.json"
deregistered=$(jq -r '.[0]' "$WORK/scriptderegistration.json")
echo "$deregistered"